-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix: retry logic for support file imports in vite-dev-server #33149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jennifer-shehane
wants to merge
15
commits into
develop
Choose a base branch
from
vite-dev-server-retry-loading-support
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+404
−101
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
cypress
|
||||||||||||||||||||||||||||||||||||||||
| Project |
cypress
|
| Branch Review |
vite-dev-server-retry-loading-support
|
| Run status |
|
| Run duration | 20m 56s |
| Commit |
|
| Committer | Jennifer Shehane |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
8
|
|
|
1098
|
|
|
4
|
|
|
26989
|
| View all changes introduced in this branch ↗︎ | |
Warning
Partial Report: The results for the Application Quality reports may be incomplete.
UI Coverage
45.18%
|
|
|---|---|
|
|
194
|
|
|
164
|
Accessibility
97.94%
|
|
|---|---|
|
|
4 critical
8 serious
3 moderate
2 minor
|
|
|
102
|
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.
Additional details
Component tests were experiencing intermittent failures with
TypeError: Failed to fetch dynamically imported modulewhen loading the support file. This occurred due to a race condition where the dynamic import executed before Vite'soptimizeDepsfinished processing the module.Vite's
optimizeDepsruns asynchronously in the background. Even though the support file is added tooptimizeDeps.entriesfor pre-bundling,server.listen()can complete before the module is ready, causing the dynamic import to fail. Vite doesn't provide an API to wait foroptimizeDepscompletion.Implemented retry logic with exponential backoff (3 attempts: 50ms, 100ms, 200ms) for support file imports. The implementation:
import()calls on each retry (browsers disallow retrying the same call per Failed dynamic import should not always be cached whatwg/html#6768)Vite's
vite:preloadErrorevent is designed for production version skew scenarios and doesn't help with dev server timing issues. Since there's no API to wait foroptimizeDeps, retry logic is the most practical solution for this race condition.Note
Listen for Vite preload errors when importing the support file, reload once to refresh assets with a sessionStorage loop guard, add targeted tests, and disable screenshots-on-failure in test fixtures.
vite:preloadErrorlistener innpm/vite-dev-server/client/initCypressTests.jsto detect failed dynamic imports of the support file.Error.messagewhen needed; on match with support file,preventDefault, set session flag (sessionStorage) to avoid reload loops, andwindow.location.reload().import(relativeUrl).npm/vite-dev-server/test/initCypressTests.spec.tsto validate listener registration, URL extraction, reload/guard behavior, and absence of retry logic; update window/sessionStorage mocks.system-tests/__snapshots__/vite_dev_server_fresh_spec.ts.jsto reflect no screenshots on failures.screenshotOnRunFailure: falseinsystem-tests/project-fixtures/react/cypress-vite.config.ts.Written by Cursor Bugbot for commit 230dc8a. This will update automatically on new commits. Configure here.
Steps to test
How has the user experience changed?
PR Tasks
cypress-documentation?type definitions?