Cypress is unable to load site in v3.5.0 due to "Parse Error"
See original GitHub issueCurrent behavior:
When attempting to resolve our site, Cypress throws an error. This was not an issue on older versions of Cypress. Our NGINX config is fairly vanilla and hasnt changed since we deployed it several months ago
error
CypressError: cy.visit() failed trying to load:
https://our-website.test.com/search-page
We attempted to make an http request to this URL but the request failed without a response.
We received this error at the network level:
> Error: Parse Error
Common situations why this would fail:
- you don't have internet access
- you forgot to run / boot your web server
- your web server isn't accessible
- you have weird network configuration settings on your computer
The stack trace for this error is:
Error: Parse Error
at TLSSocket.socketOnData (_http_client.js:451:22)
at TLSSocket.emit (events.js:194:13)
at addChunk (_stream_readable.js:296:12)
at readableAddChunk (_stream_readable.js:277:11)
at TLSSocket.Readable.push (_stream_readable.js:232:10)
at TLSWrap.onStreamRead (internal/stream_base_commons.js:165:17)
Because this error occurred during a 'before each' hook we are skipping the remaining tests in the current suite: 'Search Page tests'`
Desired behavior:
Our site loads on newer versions of Cypress (3.5.0) and up.
Steps to reproduce: (app code and test code)
example code:
/// <reference types="Cypress" />
describe('Search Page Tests', () => {
beforeEach(() => {
cy.visit('/search')
})
cy.get(`[data-qa='tabs-wrapper']`).get(`[data-qa='tab']`).contains('red').as('redButton')
cy.get(`[data-qa='tabs-wrapper']`).get('[data-qa="tab"]').contains('blue').as('blueButton')
})
it('visit the search page and search for buttons', () => {
cy.getById('searchGoToHomeButton')
.should('have.attr', 'href', '/home')
});
Steps to reproduce.
npx cypress open
Click spec from GUI and let test start. Error is thrown immediately upon attempting to resolve the page.
Versions
v3.5.0
Cypress desktop, v3.5.0, MAcOS 10.13.6, Electron(Chrome v78)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:44 (13 by maintainers)
Top Results From Across the Web
Cypress is unable to load site in v3.5.0 due to "Parse Error"
Current behavior: When attempting to resolve our site, Cypress throws an error. This was not an issue on older versions of Cypress.
Read more >cypress-io/cypress - Gitter
Hi--I'm trying to use the coverage plugin to get coverage on my client-side tests and server tests, both UI and unit, but I...
Read more >Changelog - Cypress Documentation
Fixed an issue where an unhandled promise rejection would display an incomplete error message in the command log. Fixes #24915.
Read more >Cypress ParseError: 'import' and 'export' may appear only with ...
This error is caused by the presence of modern keywords like "import" and "export" when Cypress runs in the browser.
Read more >DevTools failed to load source map - Microsoft Q&A
Dear,. 48h ago, my Sharepoint online apps suddenly stopped working. I see this error in the browser console: DevTools failed to load source ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
After doing some investigation into the “Parse Error: Invalid header value char”, it comes down to a change in Node.js that was made in Node.js 11.5.0: nodejs/node#24730
The
llhttp
HTTP parser replaced the oldhttp_parser
HTTP parser. The newer one is more maintainable; however, it also seems to be much stricter about what can be in an HTTP header. Since Cypress uses Node’s HTTP library to proxy requests to your site, invalid characters in the header will now give this error.In Cypress 3.5.0, the bundled Node.js version was upgraded to > 11.5.0 (#5849), introducing this bug.
Here is a bug in the Node.js repo talking about this issue with
llhttp
and some proposed fixes: nodejs/node#30573I believe that, in the meantime, we may be able to pass the
--http-parser=legacy
option to opt out of using the newllhttp
parser. I will work on creating a test that reproduces the “Invalid header value char” issue as well as a fix.In the meantime, a workaround would be to ensure that the headers sent by your server do not contain any special characters that are illegal in an HTTP header.
@gabbersepp I cannot share details of scripts or website over here, however I have already sent an email with some details to cypress support team.