Skip to content
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

fix: Handle large payloads sent with privileged commands #27122

Merged
merged 6 commits into from
Jun 23, 2023

Conversation

chrisbreiding
Copy link
Contributor

@chrisbreiding chrisbreiding commented Jun 23, 2023

Additional details

Running a privileged command with a large payload can cause a 413 Request Entity Too Large error in express/body-parser when on the POST /__cypress/add-verified-command request.

This is experienced with the code coverage plugin since it sends the entire coverage payload through cy.task().

The crux of the issue is that privileged commands send their args to the server via a POST request when the command is invoked (i.e. enqueued, before being run), which triggers the 413 error in express/body-parser. Those args are compared later when the command is actually run. The fix is to send a hashed version of each arg instead of sending the entire arg in order to reduce the payload size. Then when the command is run, hashes are compared instead of full values.

Steps to test

  1. Set up a simple someTask implementation in cypress.config.js. Doesn't actually need to do anything besides return null.
  2. Run this test
it('privileged command can handle a large json payload', () => {
    const hugeJson = Cypress._.times(3000).map(() => {
      return {
        key1: 'value 1',
        key2: {
          key3: 'value 3',
          key4: {
            key5: 'value 5',
          },
        },
      }
    })

    cy.task('someTask', hugeJson)
})

How has the user experience changed?

PR Tasks

@cypress
Copy link

cypress bot commented Jun 23, 2023

Passing run #48167 ↗︎

0 214 20 0 Flakiness 0

Details:

handle undefined arg in middle of arguments
Project: cypress Commit: 92b63cd108
Status: Passed Duration: 10:15 💡
Started: Jun 23, 2023 7:22 PM Ended: Jun 23, 2023 7:32 PM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@chrisbreiding chrisbreiding merged commit f5815b7 into develop Jun 23, 2023
@chrisbreiding chrisbreiding deleted the issue-27099-privileged-large-payload branch June 23, 2023 19:32
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 26, 2023

Released in 12.16.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v12.16.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jun 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cy.task() doesn't work with new Cypress version 12.15.0
3 participants