Skip to content

Add uncaught error handling for streaming procedures - #436

Open
asimawdah wants to merge 1 commit into
replit:mainfrom
asimawdah:fix/uncaught-stream-errors
Open

asimawdah wants to merge 1 commit into
replit:mainfrom
asimawdah:fix/uncaught-stream-errors

Conversation

@asimawdah

@asimawdah asimawdah commented Oct 25, 2026 •

Copy link
Copy Markdown

Why

Streaming procedure handlers may need to report errors from callbacks or background tasks that execute after the handler has returned control to the event loop. These errors cannot be handled through the handler's normal error flow, leaving no explicit way to propagate them to the client.

What changed

  • Add ctx.uncaught(error) to the procedure handler context to report uncaught server errors and notify the client.
  • Reuse the existing UNCAUGHT_ERROR error code and convert the error into a readable message.
  • Document how to report errors from callbacks and background tasks.
  • Add a regression test verifying that the client receives the expected error and the procedure's AbortSignal is aborted.
  • Exclude uncaught from MiddlewareContext.

@asimawdah
asimawdah requested a review from a team as a code owner October 25, 2026 14:06
@asimawdah
asimawdah requested review from rileyjones-dev and removed request for a team October 25, 2026 14:06

This branch has not been deployed

No deployments
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