fix(download): preserve dispatched effects when the trigger fails - #351
Merged
iuyo5678 merged 1 commit intoSep 27, 2026
Merged
Conversation
Collaborator
|
LGTM |
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
A download button can start an asynchronous export before Chrome emits a download event. If the click is cancelled or fails in that interval,
captureBrowserDownloadcan reporteffect_state: noneeven though the page's click handler has already run. An agent using that metadata to decide whether to retry may start the export twice.Use the existing dispatch marker when classifying both returned trigger errors and thrown failures. Fixes #348.
Reproduction and evidence
Failing base: 8cbcc490. Validated PR head: 7efe13a1.
The download-effect-state.browser.test.ts uses the production
handleDownloadpath and an isolated Chrome instance:window.startedExports.mouseReleasedacknowledgement.window.startedExports11cancelledcancelleddata.phasetriggertriggerdata.effect_statenone— contradicts the page counterunknownThe hosted browser log records the corrected result:
{"startedExports":1,"result":{"code":"cancelled","message":"click aborted","data":{"effect_state":"unknown","phase":"trigger"}}}Implementation
Update the error classification in download-capture.ts:
committed(existing meaning retained)unknownnoneThe marker is set immediately before sending the mouse press. It is evidence of possible delivery, not proof that a download succeeded. The returned-
RpcErrorbranch and exception branch both consult it. Existing error codes, messages, attribution and cleanup behavior remain intact.Validation
Local environment: macOS, Node 26.10.0, pnpm 10.17.0, Vitest 4.1.6, Chrome 153.0.8010.54.
file-transfer.test.tsgit diff --checkLocal focused total: 31 passed. The two new unit cases and the new browser case failed against the original implementation before the fix.
Use the repository's declared pnpm 10.17.0, from the repository root. The local runs used
npm exec --yes --package pnpm@10.17.0 -- pnpm ...to select that version. SetBSK_CLICK_CHROMEto an installed Chrome executable; without it the browser test is skipped.Hosted status for 7efe13a1, checked 2026-09-26 UTC: all 8 reported checks passed, including frontend validation, the new browser regression and existing browser suite, Rust, Windows, Node scripts and CodeCC.
Verification boundary
Chrome receives real native CDP input and executes the fixture's JavaScript. Tab/window metadata and download APIs are test adapters; the fixture does not create a real export file or call a business server. This proves the metadata contradiction, not an observed duplicate export in a production service. The test calls the extension handler directly, rather than exercising the installed CLI/daemon/extension transport end to end.
Trigger deadlines and cancellation cleanup are handled separately in #354. This PR only corrects the effect metadata and adds its regression coverage.