NServiceBus icon indicating copy to clipboard operation
NServiceBus copied to clipboard

Endpoint in endless loop when stacktrace is too long

Open JSCProjects opened this issue 5 years ago • 3 comments

When we try to handle a message which contains a lot of errors and we throw an exception with a too long message and stacktrace the endpoint is coming in an endless loop, because endpoint tries to move the message to the error queue (with all (too large) headers). Azure Service Bus gives an AMQP 37 error which is mapped to an Unknown error, and then the NServiceBus does an endless retry.

NServiceBus protects itself against too long exception messages, but the same thing also can happen with a stacktrace.

headers["NServiceBus.ExceptionInfo.Message"] = e.GetMessage().Truncate(16384);
headers["NServiceBus.ExceptionInfo.StackTrace"] = e.ToString();

I think the same truncate must be done with the stacktrace, and maybe we can better use e.StackTrace

JSCProjects avatar Sep 24 '20 07:09 JSCProjects

@JSCProjects Have you taken a look at the Stack Trace Cleaning sample in our docs? There is an example in it that shows how to reduce the size of the header text and replace the header value with that reduced text. https://docs.particular.net/samples/logging/stack-trace-cleaning/#manipulate-error-queue-header

dbelcham avatar Sep 24 '20 16:09 dbelcham

@dbelcham @SeanFeldman We are seeing this currently. Can I get an updated link to replace the broken one? Thanks!

bbrandt avatar Jun 17 '25 20:06 bbrandt

Hey @bbrandt, this PR removed the sample. Perhaps some bits and pieces could be helpful.

awright18 avatar Jun 17 '25 21:06 awright18