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

cy.request() crashes the framework when using digest authentication #28175

Closed
hyuan-mongo opened this issue Oct 29, 2023 · 4 comments
Closed
Labels
stage: needs investigating Someone from Cypress needs to look at this stale no activity on this issue for a long period topic: cy.request Issues related to cy.request command type: bug

Comments

@hyuan-mongo
Copy link

Current behavior

When using cy.request() with digest authentication, following supported auth options mentioned in the cypress documentation

        cy.request({
            method: 'GET',
            url: "https://postman-echo.com/digest-auth",
            auth: {
                username: 'postman',
                password: 'password',
                sendImmediately: false,
            },
        }).then((resp) => {
            expect(resp.status).to.eq(200)
        })

the test crashes cypress with error

The "url" argument must be of type string. Received undefined
TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:399:5)
    at validateString (node:internal/validators:163:11)
    at Url.parse (node:url:176:3)
    at urlParse (node:url:147:13)
    at Url.resolve (node:url:699:29)
    at Object.urlResolve [as resolve] (node:url:695:40)
    at o.followRedirect.o.followRedirect (<embedded>:4513:59238)
    at i.onResponse (<embedded>:2050:80181)
    at ee.onRequestResponse (<embedded>:2050:102129)
    at ClientRequest.emit (node:events:513:28)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:701:27)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
    at TLSSocket.socketOnData (node:_http_client:542:22)
    at TLSSocket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)
The Test Runner unexpectedly exited via a exit event with signal SIGABRT

Desired behavior

cy.request() should return http 200 response. using request module as an example to send the same request

const request = require('@cypress/request');

var options = {
    method: 'get',
    url: 'https://postman-echo.com/digest-auth',
    auth: {
        username: 'postman',
        password: 'password',
        sendImmediately: false,
    },
};

request.get(options, function(error, response, body){
    console.log('body : ' + body)
    // body : {
    //     "authenticated": true
    // }
});

Test code to reproduce

https://github.com/hyuan-mongo/cypress-test-tiny
forked the repo and added a case to reproduce.

Cypress Version

12.12.0, 13.3.3

Node version

v16.20.1

Operating System

macOS 13.6

Debug Logs

cypress:server:socket-base backend:request { eventName: 'http:request', args: [ { url: 'https://postman-echo.com/digest-auth', method: 'GET', auth: [Object], encoding: 'utf8', gzip: true, timeout: 30000, followRedirect: true, failOnStatusCode: true, retryIntervals: [Array], retryOnNetworkFailure: true, retryOnStatusCodeFailure: false } ] } +150ms
  cypress:server:automation:cookies getting:cookies { url: 'https://postman-echo.com/digest-auth' } +154ms
  cypress:server:automation:cookies received get:cookies [] +1ms
  cypress:server:request got cookies from browser { reqUrl: 'https://postman-echo.com/digest-auth', cookies: [] } +16ms
  cypress:network:agent addRequest called { isHttps: true, href: 'https://postman-echo.com/digest-auth' } +80ms
  cypress:network:connect beginning getAddress { hostname: 'postman-echo.com', port: 443 } +99ms
GET /__cypress/runner/fonts/fa-regular-400.woff2 200 1.395 ms - 23900
  cypress:network:connect got addresses { hostname: 'postman-echo.com', port: 443, addresses: [ { address: '34.192.200.146', family: 4 }, { address: '35.174.52.60', family: 4 }, { address: '54.173.9.70', family: 4 }, { address: '3.208.114.124', family: 4 }, { address: '3.220.25.59', family: 4 }, { address: '18.235.199.155', family: 4 } ] } +61ms
  cypress:network:agent got family { family: 4, href: 'https://postman-echo.com/digest-auth' } +81ms
The "url" argument must be of type string. Received undefined
TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:399:5)
    at validateString (node:internal/validators:163:11)
    at Url.parse (node:url:176:3)
    at urlParse (node:url:147:13)
    at Url.resolve (node:url:699:29)
    at Object.urlResolve [as resolve] (node:url:695:40)
    at o.followRedirect.o.followRedirect (<embedded>:4513:59238)
    at i.onResponse (<embedded>:2050:80181)
    at ee.onRequestResponse (<embedded>:2050:102129)
    at ClientRequest.emit (node:events:513:28)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:701:27)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
    at TLSSocket.socketOnData (node:_http_client:542:22)
    at TLSSocket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)
  cypress:server:request received an error making http request { url: 'https://postman-echo.com/digest-auth', method: 'GET', auth: { username: 'postman', password: 'password', sendImmediately: false }, encoding: 'utf8', gzip: true, timeout: 30000, failOnStatusCode: true, retryIntervals: [ 0, 100, 200, 200 ], retryOnNetworkFailure: true, retryOnStatusCodeFailure: false, headers: { 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Cypress/13.3.2 Chrome/114.0.5735.289 Electron/25.8.4 Safari/537.36', accept: '*/*' }, cookies: true, simple: false, resolveWithFullResponse: true, followAllRedirects: true, requestId: 'request5', delaysRemaining: [ 0, 100, 200, 200 ], err: Error: Parse Error: User callback error     at TLSSocket.socketOnData (node:_http_client:542:22)     at TLSSocket.emit (node:events:513:28)     at addChunk (node:internal/streams/readable:324:12)     at readableAddChunk (node:internal/streams/readable:297:9)     at Readable.push (node:internal/streams/readable:234:10)     at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23) { bytesParsed: 4393024, code: 'HPE_CB_HEADERS_COMPLETE', reason: 'User callback error', rawPacket: <Buffer 30 0d 0a 0d 0a> } } +166ms
  cypress:server:cloud:api request to url: POST https://api.cypress.io/exceptions with params: {"body":{"err":{"name":"TypeError","message":"The \"url\" argument must be of type string. Received undefined","stack":"TypeError [ERR_INVALID_ARG_TYPE]: The \"url\" argument must be of type string. Received undefined\n    at new NodeError (node:internal<stripped-path>errors:399:5)\n    at validateString (node:internal<stripped-path>validators:163:11)\n    at Url.parse (node:url:176:3)\n    at urlParse (node:url:147:13)\n    at Url.resolve (node:url:699:29)\n    at Object.urlResolve [as resolve] (node:url:695:40)\n    at o.followRedirect.o.followRedirect (<embedded>:4513:59238)\n    at i.onResponse (<embedded>:2050:80181)\n    at ee.onRequestResponse (<embedded>:2050:102129)\n    at ClientRequest.emit (node:events:513:28)\n    at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:701:27)\n    at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)\n    at TLSSocket.socketOnData (node:_http_client:542:22)\n    at TLSSocket.emit (node:events:513:28)\n    at addChunk (node:internal<stripped-path>readable:324:12)\n    at readableAddChunk (node:internal<stripped-path>readable:297:9)\n    at Readable.push (node:internal<stripped-path>readable:234:10)\n    at TLSWrap.onStreamRead (node:internal<stripped-path>stream_base_commons:190:23)"},"version":"13.3.2","osName":"darwin","osVersion":"22.6.0","osCpus":[{"model":"Apple M1 Max","speed":24,"times":{"user":253262000,"nice":0,"sys":173339750,"idle":1001864270,"irq":0}},{"model":"Apple M1 Max","speed":24,"times":{"user":253389650,"nice":0,"sys":164988430,"idle":1010154420,"irq":0}},{"model":"Apple M1 Max","speed":24,"times":{"user":126199950,"nice":0,"sys":43260140,"idle":1262418580,"irq":0}},{"model":"Apple M1 Max","speed":24,"times":{"user":75900310,"nice":0,"sys":23314180,"idle":1333363240,"irq":0}},{"model":"Apple M1 Max","speed":24,"times":{"user":43231750,"nice":0,"sys":12251090,"idle":1377657500,"irq":0}},{"model":"Apple M1 Max","speed":24,"times":{"user":24769370,"nice":0,"sys":7540250,"idle":1401197450,"irq":0}},{"model":"Apple M1 Max","speed":24,"times":{"user":24807900,"nice":0,"sys":7206390,"idle":1401811710,"irq":0}},{"model":"Apple M1 Max","speed":24,"times":{"user":12361580,"nice":0,"sys":3521610,"idle":1418206430,"irq":0}},{"model":"Apple M1 Max","speed":24,"times":{"user":8952320,"nice":0,"sys":2548500,"idle":1422700830,"irq":0}},{"model":"Apple M1 Max","speed":24,"times":{"user":7662230,"nice":0,"sys":2239480,"idle":1424324900,"irq":0}}],"osMemory":{"free":102334464,"total":34359738368}},"headers":{"x-os-name":"darwin","x-cypress-version":"13.3.2"}} and token: undefined +0ms
  cypress:network:agent addRequest called { isHttps: true, href: 'https://api.cypress.io/exceptions' } +89ms
  cypress:network:connect beginning getAddress { hostname: 'api.cypress.io', port: 443 } +109ms
  cypress:server:browsers:electron closed event fired +3s
  cypress:server:windows error removing all extensions { err: TypeError: Object has been destroyed at Object.f (<embedded>:4454:91777) at BrowserWindow.<anonymous> (<embedded>:4454:105211)     at Object.onceWrapper (node:events:628:26)     at BrowserWindow.emit (node:events:525:35) at <embedded>:4460:18960 at tryCatcher (/Users/hank.yuan/Library/Caches/Cypress/13.3.2/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/Users/hank.yuan/Library/Caches/Cypress/13.3.2/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:512:31) at Promise._settlePromise (/Users/hank.yuan/Library/Caches/Cypress/13.3.2/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:569:18) at Promise._settlePromise0 (/Users/hank.yuan/Library/Caches/Cypress/13.3.2/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:614:10) at Promise._settlePromises (/Users/hank.yuan/Library/Caches/Cypress/13.3.2/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:694:18) at _drainQueueStep (/Users/hank.yuan/Library/Caches/Cypress/13.3.2/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/async.js:138:12) at _drainQueue (/Users/hank.yuan/Library/Caches/Cypress/13.3.2/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/async.js:131:9) at Async._drainQueues (/Users/hank.yuan/Library/Caches/Cypress/13.3.2/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/async.js:147:5) at Immediate._onImmediate (/Users/hank.yuan/Library/Caches/Cypress/13.3.2/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/async.js:17:14)     at process.processImmediate (node:internal/timers:476:21), extensions: undefined } +9s
  cypress:server:browsers browser instance exit event received { code: undefined, signal: undefined } +2s
  cypress:server:browsers:electron closing remote interface client { options: {} } +0ms
  cypress:server:browsers:cri-client closing cri client { closed: false, target: '8285D746F48AEC687BF23A7F45168199' } +3s
  cypress:server:browsers browsers.kill called with no active instance +1ms
  cypress:proxy:http:util:prerequests metrics: { browserPreRequestsReceived: 32, proxyRequestsReceived: 1, immediatelyMatchedRequests: 1, unmatchedRequests: 0, unmatchedPreRequests: 0 } +0ms
  cypress:server:browsers:cri-client closed cri client { closed: true, target: '8285D746F48AEC687BF23A7F45168199' } +19ms
  cypress:server:browsers:cri-client closing cri client { closed: false, target: 'ws://127.0.0.1:51817/devtools/browser/2d926b3b-174a-445e-abb1-18a5bbb23979' } +0ms
  cypress:server:browsers:browser-cri-client Target.targetDestroyed { event: { targetId: '14D90CC7E7DB29AD58CDE190BE830C7C' }, closing: true, closed: false, resettingBrowserTargets: false } +3s
  cypress:cli child event fired { event: 'exit', code: null, signal: 'SIGABRT' } +11s
  cypress:cli detecting arch { osPlatform: 'darwin', osArch: 'arm64' } +11s
The Test Runner unexpectedly exited via a exit event with signal SIGABRT

Please search Cypress documentation for possible solutions:

https://on.cypress.io

Check if there is a GitHub issue describing this crash:

https://github.com/cypress-io/cypress/issues

Consider opening a new issue.

----------

Platform: darwin-arm64 (22.6.0)
Cypress Version: 13.3.2

Other

No response

@jennifer-shehane jennifer-shehane added type: bug stage: needs investigating Someone from Cypress needs to look at this topic: cy.request Issues related to cy.request command labels Nov 28, 2023
@hyuan-mongo
Copy link
Author

hi cypress team, any updates on this? were you able to reproduce the bug?

@David-Mueller
Copy link

David-Mueller commented Jan 17, 2024

Same issue on our side, also need the sendImmediately: false config!

@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label Jul 16, 2024
@cypress-app-bot
Copy link
Collaborator

This issue has been closed due to inactivity.

@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: needs investigating Someone from Cypress needs to look at this stale no activity on this issue for a long period topic: cy.request Issues related to cy.request command type: bug
Projects
None yet
Development

No branches or pull requests

4 participants