-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Use websockets to stub large XHR response bodies instead of headers #5525
Conversation
Thanks for the contribution! Below are some guidelines Cypress uses when doing PR reviews.
PR Review ChecklistIf any of the following requirements can't be met, leave a comment in the review selecting 'Request changes', otherwise 'Approve'. User Experience
Functionality
Maintainability
Quality
Internal
|
packages/server/lib/xhr_ws_server.ts
Outdated
debug('resetting incomingXhrs %o', { length: incomingXhrs.length }) | ||
|
||
_.forEach(incomingXhrs, ({ reject }) => { | ||
reject(new Error('This stubbed XHR was pending on a stub response object from the driver, but the test ended before that happened.')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not feel correct - tests can end while the XHR is in flight without that being an actual error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really just to ensure that the HTTP request is closed before creating new tests; otherwise, the connections would pile up until they timed out.
It could also be fulfilled with a successful response, or left to time out. Ed: Or we could try killing the socket.
Pulling this down to run against Services to see if it fixes their requests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is creating a new failure within the Services team - when running their tests in this branch.
Essentially the test is something like:
cy.server()
cy.fixture('runs').as('runs')
/// later
cy.route('runs?page=1', this.runs).as('getRuns')
The runs.json
file being quite large: https://github.com/cypress-io/cypress-services/blob/feature/cypress-3.5.0/packages/dashboard/cypress/fixtures/runs.json
Just kidding, I commented something out in the JSON 😅 rerunning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the tests that were previously failing in the Services repo. I did not review the code.
* Detect if NODE_OPTIONS are present in binary; if not, respawn * Always reset NODE_OPTIONS, even if no ORIGINAL_ Co-authored-by: Andrew Smith <andrew@andrew.codes> * Exit with correct code # from stub process * Clean up based on Brian's feedback * how process.versions is null, i have no idea, but it is * add repro for invalid header char * Always pass NODE_OPTIONS with max-http-header-size (#5452) * cli: set NODE_OPTIONS=--max-http-header-size=1024*1024 on spawn * electron: remove redundant max-http-header-size * server: add useCli option to make e2e tests go thru cli * server: add test for XHR with body > 100kb via CLI * clean up conditional * cli: don't pass --max-http-header-size in dev w node < 11.10 * add original_node_options to restore o.g. user node_options * force no color * Revert "Use websockets to stub large XHR response bodies instead of hea… (#5525)" This reverts commit 249db45. * fix yarn.lock * update 4_xhr_spec snapshot * make 6_visit_spec reproduce invalid header char error * pass --http-parser=legacy * still set headers if an ERR_INVALID_CHAR is raised * add --http-parser=legacy in some more places * update http_requests_spec * readd spawn_spec * improve debug logging * remove unnecessary changes * cleanup * revert yarn.lock to develop * use cp.spawn, not cp.fork to work around the Electron patch: https://github.com/electron/electron/blob/39baf6879011c0fe8cc975c7585567c7ed0aeed8/patches/node/refactor_alter_child_process_fork_to_use_execute_script_with.patch Co-authored-by: Andrew Smith <andrew@andrew.codes>
User facing changelog
Fixed a regression where
cy.route
stubs with a response of more than about 8 kilobytes of data would cause an HTTP 431 error to occur. Fixes #5431 #5542 #5541Additional details
X-Cypress-Response
Cookie
headers andAuthorization
headersHow has the user experience changed?
Large response stubs work.
PR Tasks