fix(runtime): acknowledge terminal commands before cleanup - #431
Merged
Conversation
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
waitUntiland log cleanup failures independently.session_runlookup and proves the acknowledgement is no longer hostage to cleanup latency.Root cause
Production runs
01KYNP1C4XG9KC16SX8RP2843Kand01KYNP5RKZW1NSYJ9G3WDBVWD9completed successfully, but each Driver failed 3–5 seconds later withterminal status could not be delivered. Production D1 takes roughly 41–62 ms per round trip. The command-update handler persisted the terminal command, then synchronously ran the linked run/lease cleanup before returning. That cleanup pushed the response past the Driver's 250 ms per-attempt deadline. The Driver retried, then self-failed, so the next message created/resumed another runtime and erased the warm-retention benefit from #400.The Chrome reproduction on the same production Worker confirmed the mechanism: 11.96 s then 10.90 s to reply, but the two runs used different Driver IDs and both Drivers subsequently failed with the same delivery error.
Verification
just test-file apps/api/tests/driver-command-terminal-ack.test.tsvp run --filter @mosoo/api tcjust commit-checkjust check: format, docs, lint, and workspace typecheck passed; tests reached 1,078 passed / 42 skipped / 1 unrelated existing failure in the pinned Driver submodule (acp-file-system.test.tscompares macOS/var/...with canonical/private/var/...). The exact Driver test fails the same way when rerun alone.Generated and persistence surfaces
Refs #387.