Skip to content
Commit Detail

Commit 687a17d

Author
Felix Hanau <felix@cloudflare.com> 2025-09-24 02:32:04 +0000
Parents
edb686a
Tree
2fc7f4f
EW-9453 Implement proper STW exception propagation

- JS exceptions will now be logged properly in all cases
- Limits exceeded exceptions no longer cause unsightly stack traces to be logged
- Exceptions are re-thrown at the level of the customEvent, instead of the
  report() call itself, ensuring that no more tail events are delivered to the
  tail worker after the exception.

Rationale for propagating exception from report() (tail event RPC call) to the
tailStream customEvent:
When we reach the catch block in report(), we are at the top-level exception
catcher of the RPC call used to report a tail event. Unlike with JsRpc, we do
not want to propagate JS exceptions to the client side (STW tail events are
reported from C++ whereas JsRpc calls are made from JS, where the client side
may want to catch exceptions). Therefore, we propagate the exception to the
doneFulfiller, where it is used to return the appropriate outcome code (for JS
exceptions) or re-throw it so it gets reported as an uncaught exception (for any
C++ exceptions). By doing this at the customEvent level and not the call level,
we also ensure that no more tail events get delivered (this previously caused
errors when the weakIoContext was no longer valid when another tail event was
reported after an exception).

Files changed

1 file changed~1 modified