Skip to content

prevent SDK retry from crashing on circular errors#13

Closed
chrisbamonday wants to merge 1 commit into
masterfrom
bug-crash-on-stringify
Closed

prevent SDK retry from crashing on circular errors#13
chrisbamonday wants to merge 1 commit into
masterfrom
bug-crash-on-stringify

Conversation

@chrisbamonday

Copy link
Copy Markdown
Collaborator

serializeError fed AxiosError directly into JSON.stringify, which
throws on the ClientRequest and IncomingMessage cycle.

The throw escaped BaseQueueProcessor.process() (logProcessingError sits outside the inner retry try/catch), so callback jobs to any 500 endpoint were silently dropped instead of being requeued.

  • log-utils: replace cycles with "[Circular]" via a WeakSet replacer
  • base-queue-processor: wrap logProcessingError in its own try/catch
    so logging failures can never break the retry path again
  • tests for both

@chrisbamonday

chrisbamonday commented May 20, 2026

Copy link
Copy Markdown
Collaborator Author

Additional explanation for the change; while testing my webhook-service when it is thrown a 500 (which triggers an exponential backoff/retry), the SDK threw a type error "circular structure into json". This was the AxiosError from a failed POST, and AI found that the ClientRequest and IncomingMessage data pointed at each other.

This finally lead to a situation where .process() was escaped entirely, and no retry was ever done.

AI recommended adding the WeakSet to replace those circular references, so it will still log and the retry path is hit. All the WeakSet is doing is replacing values when it's seen the exact same ones again, like in this case where the req has a res that points back to req

@chrisbamonday

Copy link
Copy Markdown
Collaborator Author

For additional context, in order to test this would work, i created a tarball, which i imported into webhook-relay (And therefore a second tarball) which all got worked into the webhook relay service that is on aws now. Testing showed that this prevented the broken retry behavior

@chrisbamonday chrisbamonday deleted the bug-crash-on-stringify branch May 20, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant