question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cypress is unable to load site in v3.5.0 due to "Parse Error"

See original GitHub issue

Current 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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:44 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
flotwigcommented, Jan 7, 2020

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 old http_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#30573

I believe that, in the meantime, we may be able to pass the --http-parser=legacy option to opt out of using the new llhttp 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.

2reactions
arifmasoodcommented, Nov 12, 2019

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found