Skip to content

Keep the worker serving after a handler raises - #13

Merged
m-messer merged 1 commit into
mainfrom
fix/worker-survives-handler-errors
Sep 24, 2026
Merged

m-messer merged 1 commit into
mainfrom
fix/worker-survives-handler-errors

Conversation

@m-messer

Copy link
Copy Markdown
Member

A handler exception permanently killed the worker. jsonrpc_handler passed the exception object as JSON-RPC data, which ujson cannot serialize, so building the error response raised TypeError out of dispatch(); the serve loop caught it and broke out, closing the client. The process stayed resident but never read stdin again, so every later request on that worker timed out in the shim's RPC send.

Pass only the exception message, and split the serve loop so a failed dispatch no longer ends the session. Read and write failures still stop serving, since a partial frame leaves no safe point to resume from.

A handler exception permanently killed the worker. jsonrpc_handler passed
the exception object as JSON-RPC `data`, which ujson cannot serialize, so
building the error response raised TypeError out of dispatch(); the serve
loop caught it and broke out, closing the client. The process stayed
resident but never read stdin again, so every later request on that worker
timed out in the shim's RPC send.

Pass only the exception message, and split the serve loop so a failed
dispatch no longer ends the session. Read and write failures still stop
serving, since a partial frame leaves no safe point to resume from.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@m-messer
m-messer merged commit 1be4153 into main Sep 24, 2026
1 check passed
@m-messer
m-messer deleted the fix/worker-survives-handler-errors branch September 24, 2026 14:32
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