Skip to content

fix: add unhandledRejection handler and fix Polygon init crash#3566

Open
TaprootFreak wants to merge 1 commit intodevelopfrom
fix/unhandled-rejection-handler
Open

fix: add unhandledRejection handler and fix Polygon init crash#3566
TaprootFreak wants to merge 1 commit intodevelopfrom
fix/unhandled-rejection-handler

Conversation

@TaprootFreak
Copy link
Copy Markdown
Collaborator

Summary

  • Add global unhandledRejection handler in main.ts to prevent process crashes from escaped promise rejections (Node 22 defaults to --unhandled-rejections=throw)
  • Fix Polygon POSClient fire-and-forget initialization (void) that would crash the process if the RPC endpoint is unreachable at startup

Context

Follow-up to #3562 — after the Spark SDK crash, audit revealed two additional crash vectors from external SDKs:

  1. No unhandledRejection handler: Any SDK that rejects a promise outside a .catch() chain kills the process
  2. Polygon void init: void this.initPolygonNetwork(...) silently discards the promise, making any rejection unhandled

Test plan

  • Verify build passes
  • Verify API starts correctly in DEV
  • Check AppInsights for UnhandledRejection log entries after deploy

Add global unhandledRejection handler to prevent process crashes from
escaped promise rejections (Node 22 defaults to --unhandled-rejections=throw).

Fix Polygon POSClient fire-and-forget initialization that could crash
the process if the RPC endpoint is unreachable at startup.
@TaprootFreak TaprootFreak marked this pull request as ready for review April 9, 2026 22:26
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