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

ERR_INVALID_ARG_TYPE still present after the fix #16223

Closed
Jacek-fstack opened this issue Apr 27, 2021 · 10 comments · Fixed by #16306
Closed

ERR_INVALID_ARG_TYPE still present after the fix #16223

Jacek-fstack opened this issue Apr 27, 2021 · 10 comments · Fixed by #16306
Labels
topic: cy.intercept() type: regression A bug that didn't appear until a specific Cy version release

Comments

@Jacek-fstack
Copy link

#15901

Fixed a regression in 7.0.0 that caused the Test Runner to crash with an ERR_INVALID_ARG_TYPE type error. We now correctly detect a utf8 request body with multi-byte Unicode characters. Fixes #15901.

It's still present in my tests. I'm using cypress-file-upload plugin and it happens when I want to upload an image file. Crashes the whole run.

TypeError [ERR_INVALID_ARG_TYPE] [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer or Uint8Array. Received type number (45)

Version 7.2.0

@iozz
Copy link

iozz commented Apr 27, 2021

Same for me, the runner is still crashing on our test runs.

@EliasJorgensen
Copy link

EliasJorgensen commented Apr 27, 2021

This is also still happening for us, when intercepting an image upload. The following code has been working fine on Cypress v6:

    it('Can edit resource image', () => {
        cy.intercept({
            method: 'POST',
            url: '**/img'
        }).as('imageUpload')

        cy.get('#upload-input')
            .attachFile('hackerman.jpg')

        cy.get('button[type="submit"]').click()

        cy.wait('@imageUpload').then((interception) => {
            assert.equal(interception.response.statusCode, 200)
        })

        cy.contains('The resource was updated')
    })

Now the runner is crashing with the error:

TypeError [ERR_INVALID_ARG_TYPE] [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer or Uint8Array. Received type number (45)
    at write_ (_http_outgoing.js:696:11)
    at ClientRequest.write (_http_outgoing.js:661:15)
    at Request.write (/home/elias/.cache/Cypress/7.2.0/Cypress/resources/app/packages/server/node_modules/@cypress/request/request.js:1496:27)
    at /home/elias/.cache/Cypress/7.2.0/Cypress/resources/app/packages/server/node_modules/@cypress/request/request.js:546:20
    at Array.forEach (<anonymous>:null:null)
    at end (/home/elias/.cache/Cypress/7.2.0/Cypress/resources/app/packages/server/node_modules/@cypress/request/request.js:545:23)
    at Immediate._onImmediate (/home/elias/.cache/Cypress/7.2.0/Cypress/resources/app/packages/server/node_modules/@cypress/request/request.js:578:7)
    at processImmediate (internal/timers.js:461:21)

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Apr 27, 2021

We did fix the issue that was reproducible at the time of release, but there are still cases of this failing that we could not address because no one provided a way to reproduce them before the next release.

We are working on this one now: #15898 where there was a reproducible example provided today in this repo: https://github.com/verheyenkoen/cypress-upload-intercept-problem This may be a duplicate of the issue you're experiencing but we can't know without a reproducible example.

Please provide a fully reproducible example that we can run and see Cypress crashing.

In the meantime we suggest downgrading to the most recent version of Cypress that does not crash.

@jennifer-shehane jennifer-shehane added stage: needs information Not enough info to reproduce the issue type: regression A bug that didn't appear until a specific Cy version release labels Apr 27, 2021
@todd-m-kemp
Copy link

todd-m-kemp commented Apr 27, 2021

I'm still experiencing this problem as well and can provide a fully reproducible example.

Steps to Reproduce:

(1) Run the following test code; the test will pass but continue with step (2) to experience the crash.

context('Cypress Issue', function () {

  beforeEach(function () {

    // These are not real credentials.
    // Please sign up (for free) at www.vidyard.com, verify your email address, then update these accordingly.

    const email = 'test@fake.com'
    const password = 'A123456b!'

    cy.visit('https://secure.vidyard.com/user/sign_in')
    cy.get('#username').type(email)
    cy.get('#password').type(password)
    cy.get('#sign-in').click()
  })

  it('Cypress Crash', function () {
    cy.intercept('PUT', '/uploads/videos/**').as('uploadDuration');
  });
});

(2) In the Test Runner, click New -> Upload and select a video file to upload.

At this point, the Cypress process will crash, producing the following output:

TypeError [ERR_INVALID_ARG_TYPE] [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer or Uint8Array. Received type number (0)
    at write_ (_http_outgoing.js:696:11)
    at ClientRequest.write (_http_outgoing.js:661:15)
    at Request.write (/Users/tkemp/Library/Caches/Cypress/7.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:1496:27)
    at /Users/tkemp/Library/Caches/Cypress/7.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:546:20
    at Array.forEach (<anonymous>:null:null)
    at end (/Users/tkemp/Library/Caches/Cypress/7.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:545:23)
    at Immediate._onImmediate (/Users/tkemp/Library/Caches/Cypress/7.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:578:7)
    at processImmediate (internal/timers.js:461:21)
 {
  code: 'ERR_INVALID_ARG_TYPE'
}
TypeError [ERR_INVALID_ARG_TYPE] [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer or Uint8Array. Received type number (0)
    at write_ (_http_outgoing.js:696:11)
    at ClientRequest.write (_http_outgoing.js:661:15)
    at Request.write (/Users/tkemp/Library/Caches/Cypress/7.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:1496:27)
    at /Users/tkemp/Library/Caches/Cypress/7.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:546:20
    at Array.forEach (<anonymous>:null:null)
    at end (/Users/tkemp/Library/Caches/Cypress/7.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:545:23)
    at Immediate._onImmediate (/Users/tkemp/Library/Caches/Cypress/7.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:578:7)
    at processImmediate (internal/timers.js:461:21)

Without the call to cy.intercept, Cypress does not crash.

@jennifer-shehane
Copy link
Member

@todd-m-kemp I can recreate the issue from your example given. I'm not sure if these are related or not until we investigate, but will send this example to the developer investigating.

@lugosium
Copy link

lugosium commented May 2, 2021

same for us, cypress crash

@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 3, 2021

The code for this is done in cypress-io/cypress#16306, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@jennifer-shehane
Copy link
Member

If you would like to download the pre-release version of Cypress to get this fix. Follow the instructions here

@lugosium
Copy link

lugosium commented May 4, 2021

If you would like to download the pre-release version of Cypress to get this fix. Follow the instructions here

Working perfectly 💯, thank you @jennifer-shehane

@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 10, 2021

Released in 7.3.0.

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

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators May 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: cy.intercept() type: regression A bug that didn't appear until a specific Cy version release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants