Repository navigation
Conversation
The timeout handler only cleared done and returned 504; initSubStore kept running and could still write user data after the caller had given up. Add an aborted flag and cancel() to the request context. On timeout (HTTP and cron), cancel() marks the context and detaches done; ignores cancelled contexts and flushSubStoreRequestContext refuses to persist late writes. The HTTP timeout is now injectable for tests (default unchanged). Add regression tests covering cancel semantics, the flush gate, and a full 504 path where a late script write must not be persisted.
Fix the full-504 regression test: previously the 'late' write happened at 10ms with a 50ms timeout (i.e. before cancellation). Now the write is triggered only after the 504 response, proving it is genuinely late. Gate .post on ctx.aborted so timed-out scripts cannot send Telegram/Bark/etc. Include the shared test hooks loader and wire the suite into CI.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The timeout handler only cleared
doneand returned 504.initSubStorekept running and could still write user data after the caller gave up.
The request context now has an
abortedflag andcancel(). On timeout(HTTP and cron),
cancel()marks the context and detachesdone;$doneignores cancelled contexts and
flushSubStoreRequestContextrefuses topersist late writes.
$notification.postis also gated onaborted, so atimed-out script can no longer trigger Telegram/Bark/etc. notifications.
JavaScript cannot forcibly kill a script already handed to the global
dispatch. This fix gates all side-effect exits so work that continues after
timeout cannot produce a persisted or notified effect.
Tests
504 response. Previously it wrote at 10 ms with a 50 ms timeout, i.e.
before cancellation, so it did not actually prove the fix.
The Workers CI job now runs these Node tests.
Part of the split from the original combined PR.