DeprecationWarning: OutgoingMessage.prototpye._headers is deprecated
Everything works fine until it should return the response.
this error message is displayed: DeprecationWarning: OutgoingMessage.prototpye._headers is deprecated
What version of Express are you using? This was an issue but resolved a while back, so maybe just outdated Express version being used.
v 4.17.1
It works fine on my local machine, only getting this error on my Ubuntu server Node version: 12.16.3
Hmm.. I searched through the code and don't see it being used anywhere. Can you provide a stack trace for the deprecation? https://nodejs.org/dist/latest-v14.x/docs/api/cli.html#cli_trace_deprecation
Hey didn't exactly got what to do.
got something like that when loading my file:
settings: {
'x-powered-by': true,
etag: 'weak',
'etag fn': [Function: generateETag],
env: 'development',
'query parser': 'extended',
'query parser fn': [Function: parseExtendedQueryString],
'subdomain offset': 2,
'trust proxy': false,
'trust proxy fn': [Function: trustNone],
view: [Function: View],
views: 'C:\\Users\\Basti\\Desktop\\ticket-api\\views',
'jsonp callback name': 'callback'
},
locals: [Object: null prototype] {
settings: {
'x-powered-by': true,
etag: 'weak',
'etag fn': [Function: generateETag],
env: 'development',
'query parser': 'extended',
'query parser fn': [Function: parseExtendedQueryString],
'subdomain offset': 2,
'trust proxy': false,
'trust proxy fn': [Function: trustNone],
view: [Function: View],
views: 'C:\\Users\\Basti\\Desktop\\ticket-api\\views',
'jsonp callback name': 'callback'
}
},
mountpath: '/',
_router: [Function: router] {
params: {},
_params: [],
caseSensitive: false,
mergeParams: undefined,
strict: false,
stack: [ [Layer], [Layer], [Layer], [Layer] ]
}
}
It is likely introduced by another package, some middleware perhaps, or even an older version of node-fetch.
A reproduction case would be best, but posting your list of dependencies might help as well. If you get a chance, can you post the output of the following commands run from your project's folder? It will give us an idea of the dependencies you're using.
npm ls --depth=0
npm outdated
Thanks!
My code: https://pastebin.com/wdRrw77z Works fine on local machine but not on ubuntu server as already mentioned.
Dependencies:
"dependencies": {
"body-parser": "^1.19.0",
"cheerio": "^1.0.0-rc.3",
"express": "^4.17.1",
"fs": "0.0.1-security",
"node-fetch": "^2.6.0",
"universal-analytics": "^0.4.20",
"wasm2js": "^0.2.0"
}
npm ls --depth=0 returns
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
-- [email protected]
npm outdated returns nothing
I was able to run the script on my server by using res.send(data) instead of res.json(data)
Hmm very strange. I'd suggest double checking what version of Express is running in production, maybe there's an old package-lock.json sticking around on the prod server that is forcing an outdated Express version? That's one possibility I can think of.
res.json still uses res.send under the hood, and both use the same res.set to set headers, so I'm not sure at all why the issue would be solved using res.send.
Hey @SebastianBoehler!
Has the issue been resolved for you? Or do you still face the issue. If yes, please provide a MCVE for us to take a look at. If not, you can close this issue.
Closing stale issue.
For my case issue is not related to express. http.ServerResponse is node.js class, could be any other package using it. To debug:
process.on('warning', (warning) => {
console.log(warning.stack);
});
My output:
(Use `node --trace-deprecation ...` to show where the warning was created)
DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
at Test.Request._redirect (/Users/<user>/<my-app>/node_modules/superagent/lib/node/index.js:419:26)
npm ls --depth=2 | grep 'chai\|super'
├─┬ [email protected]
│ └─┬ [email protected]