fix: resolve wait --download race condition#664
Open
juliobrasa wants to merge 1 commit intovercel-labs:mainfrom
Open
fix: resolve wait --download race condition#664juliobrasa wants to merge 1 commit intovercel-labs:mainfrom
juliobrasa wants to merge 1 commit intovercel-labs:mainfrom
Conversation
Previously, `wait --download` called `page.waitForEvent('download')`
lazily — only when the command arrived. If the download was triggered
by a prior `click` command, the event had already fired and the
listener missed it, causing a timeout.
Fix: register a `page.on('download')` listener eagerly in
`setupPageTracking()` to queue downloads as they occur. The new
`waitForDownload()` method checks the queue first before waiting
for a new event, eliminating the race condition.
Closes vercel-labs#561
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
Someone is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
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
wait --downloadalways times out if the download was triggered before the command is sent (e.g., by a priorclick). This is becausepage.waitForEvent('download')is called lazily and misses events that already fired.Fix
page.on('download')eagerly insetupPageTracking()to queue downloads as they occurwaitForDownload()method checks the pending queue first, then falls back topage.waitForEvent()Before
After
Test plan
wait --downloadwait --downloadstill works when called before the download startsCloses #561
🤖 Generated with Claude Code