Nock: OutgoingMessage.prototype._headerNames is deprecated

Created on 1 Aug 2019  路  6Comments  路  Source: nock/nock

Greetings folks!
We are running into an error with our tests while using nock:

Node.js version: v12.7.0
Test framework: mocha
Nock version: 10.0.0
--throw-deprecation enabled on tests

When we use this call:

nock(HOST_ADDRESS)
    .get(path, undefined, {reqheaders: HEADERS})
    .reply(statusCode, {access_token: 'abc123', expires_in: 10000}, HEADERS);

We are getting a stack trace like this:

 DeprecationWarning: Could not refresh access token: OutgoingMessage.prototype._headerNames is deprecated
      at setHeader (node_modules/nock/lib/request_overrider.js:34:24)
      at /Users/beckwith/Code/google-auth-library-nodejs/node_modules/nock/lib/request_overrider.js:108:7
      at /Users/beckwith/Code/google-auth-library-nodejs/node_modules/lodash/lodash.js:4905:15
      at baseForOwn (node_modules/lodash/lodash.js:2990:24)
      at Function.forOwn (node_modules/lodash/lodash.js:13014:24)
      at RequestOverrider (node_modules/nock/lib/request_overrider.js:107:7)
      at new OverriddenClientRequest (node_modules/nock/lib/intercept.js:260:23)
      at /Users/beckwith/Code/google-auth-library-nodejs/node_modules/nock/lib/intercept.js:395:13
      at module.request (node_modules/nock/lib/common.js:140:14)
      at /Users/beckwith/Code/google-auth-library-nodejs/node_modules/node-fetch/lib/index.js:1432:15
      at new Promise (<anonymous>)
      at fetch (node_modules/node-fetch/lib/index.js:1401:9)
      at Gaxios.request (node_modules/gaxios/src/gaxios.ts:81:27)
      at Gaxios.request (node_modules/gaxios/src/gaxios.ts:99:21)
      at metadataAccessor (node_modules/gcp-metadata/src/index.ts:62:17)
      at Compute.refreshTokenNoCache (src/auth/computeclient.ts:54:79)
      at Compute.getRequestMetadataAsync (src/auth/oauth2client.ts:405:4)
      at Compute.requestAsync (build/src/auth/oauth2client.js:52:1990)
      at Context.<anonymous> (test/test.compute.ts:65:3)

After testing .. it does look like this is resolved in 11.0.0-beta.30 :)

Most helpful comment

Since we've published it to next, I you should also be able to use 11.0.0.

All 6 comments

Hi! Thanks for the report. And nice to know that we've fixed it :)

@paulmelnikow if this is fixed in beta, should the issue be closed or left open until v11 goes general?

We usually close when the beta branch is patched, so I think this can be closed.

Also having this issue 鉂わ笍

@bnb can you verify it works for you when using the latest beta release?

Since we've published it to next, I you should also be able to use 11.0.0.

Was this page helpful?
0 / 5 - 0 ratings