[core] Forward-port: don't flag wait_completed.resumeAt mismatch without a recorded value (#2177)#2186
Open
VaguelySerious wants to merge 1 commit into
Open
Conversation
…rded value Forward-port of #2177 from stable to main. A reused/duration sleep races a `wait_completed` replay against a non-deterministic, wall-clock-derived expected value, producing a false CorruptedEventLogError on a perfectly consistent event log. `sleep(<ms|string>)` computes its resumeAt as `Date.now() + duration`. The original run records that absolute timestamp into both wait_created and wait_completed. During replay the VM clock advances to each event's createdAt, so a freshly-created sleep recomputes a different absolute resumeAt. Normally harmless: the wait_created consumer overwrites the queue item's resumeAt with the recorded (authoritative) value before wait_completed is validated. The bug: when a wait_completed is consumed by a sleep consumer that never applied a wait_created (hasCreatedEvent=false), the queue item still holds the freshly-recomputed value, and the resumeAt comparison fails — even though the event log is internally consistent and the recorded resumeAt is the source of truth. Fix: only validate resumeAt when an authoritative recorded value is available (hasCreatedEvent=true). When it is not, the correlationId match already establishes the wait's identity, so skip the check. Extracted into `detectResumeAtMismatch`. Co-Authored-By: Nathan Rajlich <n@n8.io> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: b1855a1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
🧪 E2E Test Results❌ Some tests failed Summary
❌ Failed Tests▲ Vercel Production (5 failed)fastify (2 failed):
nextjs-turbopack (1 failed):
nuxt (2 failed):
📦 Local Production (1 failed)hono-stable (1 failed):
📋 Other (1 failed)e2e-local-prod-nest-stable (1 failed):
Details by Category❌ ▲ Vercel Production
✅ 💻 Local Development
❌ 📦 Local Production
✅ 🐘 Local Postgres
✅ 🪟 Windows
❌ 📋 Other
❌ Some E2E test jobs failed:
Check the workflow run for details. |
Contributor
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.
Forward-port of #2177 from
stabletomain.Note
Stacked on #2185 (the forward-port of #2171). 2177's
sleep.tschanges build directly on 2171's runtime changes (sharedwait_completedconsumer andawaitEarlierDeliveries/registerDeliveryBarrierimports), so this PR is based on the 2171 forward-port branch. Retarget tomainonce #2185 merges. The diff shown here is 2177's contribution only.Summary
Fixes a second, independent source of
CORRUPTED_EVENT_LOGon replay: await_completedwhoseresumeAtis validated against a non-deterministic, wall-clock-derived value, producing a false corruption error on a perfectly consistent event log.sleep(<ms|string>)computesresumeAt = Date.now() + duration. On replay the VM clock advances to each event'screatedAt, so a freshly-created sleep recomputes a different absoluteresumeAt. This is normally overwritten by the recorded value viawait_created— but when await_completedis consumed by a sleep consumer that never applied await_created(hasCreatedEvent=false), the queue item still holds the recomputed value and the comparison falsely fails.Fix: only validate
resumeAtwhen an authoritative recorded value is available (hasCreatedEvent=true); otherwise the correlationId match already establishes identity, so skip the check. Validation extracted intodetectResumeAtMismatch.See #2177 for full root-cause analysis (incl. production instrumentation data).
Validation
stable...head, which already excludes 2171) onto the 2171 forward-port branch — clean, content-identical to the original PR.@workflow/coretypecheck: clean.sleep,hook-sleep-interaction,async-deserialization-orderingtests: 58/58 pass (incl. the newhasCreatedEvent=falseregression test).Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com