EW-6888 Improve finishScheduled() outcome reporting#6606
Conversation
There was a problem hiding this comment.
I'm Bonk, and I've done a quick review of your PR.
This PR changes finishScheduled() to return EventOutcome directly instead of the internal FinishScheduledResult enum, improving outcome reporting by propagating richer error information from outcomeFromException().
Issues found (ranked by severity):
- [HIGH] All three new
DetailTypeIdconstants are placeholder0x0ull— they collide with each other and will cause incorrect dispatching inoutcomeFromException(). - [MEDIUM] Leftover commented-out code and bare
// TODOcomments appear to be debug artifacts that should not be merged. - [LOW] The
outcomeFromExceptionfunction takes a non-const lvalue reference but doesn't modify the exception — should beconst.
This review was generated by an AI assistant and may contain inaccuracies.
| constexpr kj::Exception::DetailTypeId SCRIPT_KILLED_DETAIL_ID = 0x0ull; | ||
| constexpr kj::Exception::DetailTypeId INACTIVE_WEBSOCKETS_DETAIL_ID = 0x0ull; | ||
| constexpr kj::Exception::DetailTypeId SCRIPT_NOT_FOUND_DETAIL_ID = 0x0ull; |
There was a problem hiding this comment.
[HIGH] These three DetailTypeId constants are all 0x0ull, meaning they're indistinguishable at runtime. getDetail() uses the ID as a key, so SCRIPT_KILLED_DETAIL_ID, INACTIVE_WEBSOCKETS_DETAIL_ID, and SCRIPT_NOT_FOUND_DETAIL_ID will all match the same detail entry. The first branch that checks any of these will match (or none will), making the subsequent branches dead code.
The existing IDs in the codebase all use unique random 64-bit values (e.g. CPU_LIMIT_DETAIL_ID = 0xfdcb787ba4240576ull). These need real, distinct IDs — or if the detail IDs don't exist yet on the exception-producing side, this dispatch logic can't work and should be restructured.
I understand the // TODO comment suggests this is WIP, but as-is this would silently misclassify outcomes if merged.
|
|
||
| kj::Promise<IoContext_IncomingRequest::FinishScheduledResult> IoContext::IncomingRequest:: | ||
| finishScheduled() { | ||
| // TODO |
There was a problem hiding this comment.
[MEDIUM] Bare // TODO without explanation — if this is a reminder to assign real IDs, please make the TODO actionable (e.g. // TODO(felix): Assign unique DetailTypeId values; these are placeholders).
| // TODO | ||
| if (scheduledResult == EventOutcome::EXCEEDED_CPU) { | ||
| // if (result == IoContext_IncomingRequest::FinishScheduledResult::TIMEOUT) { |
There was a problem hiding this comment.
[MEDIUM] Leftover debug artifacts — the bare // TODO on line 965 and the commented-out old code on line 967 look like they shouldn't be merged. If there's an open question here, make the TODO actionable; otherwise please clean these up.
| // TODO | |
| if (scheduledResult == EventOutcome::EXCEEDED_CPU) { | |
| // if (result == IoContext_IncomingRequest::FinishScheduledResult::TIMEOUT) { | |
| if (scheduledResult == EventOutcome::EXCEEDED_CPU) { |
| constexpr kj::Exception::DetailTypeId SCRIPT_NOT_FOUND_DETAIL_ID = 0x0ull; | ||
|
|
||
| // TODO: Try to generalize this. Are all outcomes needed here? | ||
| EventOutcome outcomeFromException(kj::Exception& e) { |
There was a problem hiding this comment.
[LOW] This function doesn't modify the exception — consider taking const kj::Exception& instead of kj::Exception&.
| EventOutcome outcomeFromException(kj::Exception& e) { | |
| EventOutcome outcomeFromException(const kj::Exception& e) { |
|
Review posted on PR #6606 with 4 inline comments. Summary of findings:
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6606 +/- ##
==========================================
- Coverage 70.85% 70.84% -0.02%
==========================================
Files 438 438
Lines 123717 123738 +21
Branches 19470 19476 +6
==========================================
Hits 87660 87660
- Misses 24530 24552 +22
+ Partials 11527 11526 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
e236918 to
bdfac0b
Compare
Merging this PR will degrade performance by 28.41%
Performance Changes
Comparing Footnotes
|
No description provided.