-
Notifications
You must be signed in to change notification settings - Fork 3.4k
feat: timeout diagnostics #33023
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
lucgonp
wants to merge
13
commits into
cypress-io:develop
Choose a base branch
from
lucgonp:feat/timeout-diagnostics
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.
Open
feat: timeout diagnostics #33023
+687
−3
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
Collaborator
|
671295a to
fdf2196
Compare
Add smart diagnostic suggestions for timeout errors to improve DX
- Created TimeoutDiagnostics module with contextual error analysis
- Detects common timeout patterns:
* Dynamic/loading content selectors
* Complex and fragile selectors
* Dynamic ID selectors
* Network-related delays
* Animation issues
* Excessive DOM mutations
- Provides actionable suggestions with docs links
- Includes comprehensive test coverage (17 tests)
- Fully documented with examples and integration guide
Benefits:
- Reduces debugging time for developers
- Provides inline education about best practices
- Decreases frustration with clearer error messages
- Reduces support questions about timeouts
Example output:
`
cy.get() timed out waiting 4000ms
Diagnostic Suggestions:
1. The selector appears to target dynamic/loading content
a) Wait for the loading state to complete
b) Consider using data-cy attributes
c) Use cy.intercept() to wait for API requests
Learn more: https://on.cypress.io/best-practices
`
Related: Timeout errors are one of the most common issues users face
Fix critical bugs identified by Cursor Bot code review:
1. **Missing body tag handling in Vite plugin**
- Added check for missing </body> tag (lastIndexOf returns -1)
- Prevents malformed HTML with script at wrong position
- Gracefully appends script at end if body tag not found
- Added debug logging for missing body tag case
2. **Contradictory loading content suggestion**
- Fixed confusing suggestion for loading selectors
- Now suggests waiting for loading to disappear THEN get content
- Provides alternative to wait for API request
- Clarifies when user actually needs the loading element itself
3. **Unescaped quotes in generated code suggestions**
- All selectors now properly escaped before interpolation
- Prevents syntax errors like: cy.get('[data-test='value']')
- Correctly generates: cy.get('[data-test=\\'value\\']')
- Applied to all suggestion types (dynamic, complex, ID, general)
Test coverage:
- Added tests for quote escaping in selectors
- Verified proper handling of special characters
- All 19 tests passing
- Lint checks passing
Before:
- cy.get('[data-test='value']') // SYNTAX ERROR
After:
- cy.get('[data-test=\\'value\\']') // VALID
Related: Security and code quality improvements
708299f to
b611123
Compare
b611123 to
454b5db
Compare
d11c142 to
77deef7
Compare
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
Steps to test
How has the user experience changed?
PR Tasks
cypress-documentation?type definitions?Note
Introduces a timeout diagnostics module that augments timeout errors with contextual suggestions, adds unit tests and README, updates changelog, and makes Vite dev server HTML injection robust when is missing.
packages/driver/src/cypress/timeout_diagnostics.tsto analyze timeout context and append actionable suggestions to error messages (analyze,formatSuggestions,enhanceTimeoutError).TIMEOUT_DIAGNOSTICS_README.mdand unit testspackages/driver/test/unit/cypress/timeout_diagnostics.spec.tscovering selectors, network, animations, DOM mutations, escaping, and formatting.npm/vite-dev-server/src/plugins/cypress.tsto safely inject loader script even when</body>is absent; logs viadebugand appends at end of HTML as fallback.cli/CHANGELOG.mdto list the new timeout diagnostics under**Features:**for15.7.1.Written by Cursor Bugbot for commit 7f48063. This will update automatically on new commits. Configure here.