Skip to content

Improve event outcome handling#6542

Merged
fhanau merged 2 commits intomainfrom
felix/032526-exception-outcome
Apr 14, 2026
Merged

Improve event outcome handling#6542
fhanau merged 2 commits intomainfrom
felix/032526-exception-outcome

Conversation

@fhanau
Copy link
Copy Markdown
Contributor

@fhanau fhanau commented Apr 9, 2026

This includes a number of smaller changes to provide better event outcome handling and more closely correspond to the edge runtime behavior.

  • In server.c++, report proxyDisconnect and memoryExceeded outcomes properly. This should cover all outcomes that can be reported using exceptions in workerd so far
  • Return a 503 error for overloaded-type exceptions – matches what we already do in WorkerEntrypoint::request()
  • Add a missing exception detail to ensure actor-cache exception leads to memoryExceeded outcome
  • Simplify reportFailure() calls based on FailureSource::OTHER being the default value for the 2nd parameter

Also see the downstream PR

@fhanau fhanau requested review from a team as code owners April 9, 2026 16:05
Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm Bonk, and I've done a quick review of your PR.

This PR improves event outcome reporting by mapping exception types to appropriate EventOutcome values and returning 503 for overloaded exceptions.

Issues found (ranked by severity):

  1. Build-breaking: wrong variable name e vs exceptionreportFailure() names the parameter exception but the body uses e. Same issue in the request() catch block. This won't compile.
  2. Build-breaking: RequestOutcome does not exist — The code uses RequestOutcome::PROXY_DISCONNECT and RequestOutcome::EXCEPTION, but the type is EventOutcome. There is no RequestOutcome in the codebase.
  3. Build-breaking: EventOutcome::MEMORY_LIMIT_EXCEEDED does not exist — The correct enum value is EventOutcome::EXCEEDED_MEMORY (see outcome.capnp and existing usage in the codebase). Similarly, there is no PROXY_DISCONNECT; the closest match is EventOutcome::RESPONSE_STREAM_DISCONNECTED.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Apr 9, 2026

I'm Bonk, and I've done a quick review of your PR.

This PR improves event outcome reporting by mapping exception types to appropriate EventOutcome values and returning 503 for overloaded exceptions.

3 build-breaking issues found (all in src/workerd/server/server.c++):

  1. Wrong variable name e vs exceptionreportFailure() names its parameter exception but the body references e in three places (lines 1608, 1611, 1635). This won't compile.

  2. RequestOutcome does not exist — Lines 1612 and 1614 use RequestOutcome::PROXY_DISCONNECT and RequestOutcome::EXCEPTION, but the actual type is EventOutcome. There is no RequestOutcome anywhere in the codebase.

  3. EventOutcome::MEMORY_LIMIT_EXCEEDED does not exist — Line 1609 uses this value, but the correct enum member is EventOutcome::EXCEEDED_MEMORY (per outcome.capnp). Similarly, PROXY_DISCONNECT is not a member; the closest match is RESPONSE_STREAM_DISCONNECTED.

Suggestions with fixes have been posted inline on the PR.

github run

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

The generated output of @cloudflare/workers-types matches the snapshot in types/generated-snapshot 🎉

@fhanau fhanau force-pushed the felix/032526-exception-outcome branch 2 times, most recently from a0cc721 to f84d582 Compare April 9, 2026 16:43
@fhanau fhanau requested review from dom96 and harrishancock April 9, 2026 21:39
@fhanau fhanau force-pushed the felix/032526-exception-outcome branch 2 times, most recently from 2031bc6 to 17c5011 Compare April 14, 2026 02:05
fhanau added 2 commits April 14, 2026 15:32
This includes a number of smaller changes to provide better event outcome
handling and more closely correspond to the edge runtime behavior.
- In server.c++, report exceededMemory and responseStreamDisconnected outcomes
  properly. This should cover all outcomes that can be reported using exceptions
  in workerd so far
- Return a 503 error for overloaded-type exceptions - matches what we already do
  in WorkerEntrypoint::request()
- Add a missing exception detail to ensure actor-cache exception leads to
  memoryExceeded outcome
- Simplify reportFailure() calls based on FailureSource::OTHER being the default
  value for the 2nd parameter
Outcomes via reportFailure() will be reported over outcomes reported through the
event outcome, so we need to set this here so that the right outcome gets
reported to observability.
@fhanau fhanau force-pushed the felix/032526-exception-outcome branch from 17c5011 to 7b401e7 Compare April 14, 2026 15:32
@fhanau fhanau merged commit 80a327c into main Apr 14, 2026
22 of 23 checks passed
@fhanau fhanau deleted the felix/032526-exception-outcome branch April 14, 2026 16:21
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.

2 participants