7

Getting NodeJS deprecation error when execute an AWS Lambda (using node 12.x):

[DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated

can not find which module/piece of code is producing it. Nothing seems to reference _headers or _headerNames.

In Node should be possible to set a parameter or environment variable as explain here to --trace-deprecation and/or --trace-warnings and/or --throw-deprecation. When setting one or multiple of these values in AWS Console Environment variables for the lambda, no extra information is displayed.

AWS lambda environment variables

What is the way to set this runtime parameter for an AWS Lambda? Is there a way to catch the stack trace to know where is the deprecated error happening?

9
  • hard to say anything without looking at what code you have inside your lambda function Commented Mar 5, 2020 at 13:55
  • Hi @riga, looks that one of your dependencies are using the deprecated _headers ( nodejs.org/api/… ), can you post the code ? Commented Mar 5, 2020 at 16:41
  • @pepo i know this, my problem is to find which one. Commented Mar 5, 2020 at 16:52
  • 1
    Hi @riga, Oks. For enable the tracing you can use the NODE_OPTIONS env variable like this NODE_OPTIONS='--trace-deprecation'' (nodejs.org/api/cli.html#cli_node_options_options) Commented Mar 5, 2020 at 17:27
  • 1
    Hi @riga, I just made a quick test ( gist.github.com/pepoviola/aaba2d7af4d1b443b37e109f2702e358 ) setting that env variable and works as expected. Also, you can use process.on('warning', warning => console.log( warning.stack ) ); to console.log the stack. Commented Mar 5, 2020 at 19:05

1 Answer 1

3

feliz de ayudar! I pasted the snippet for the future.

set the flag in webpack.config.js code as explained here

process.traceDeprecation = true;

module.exports = {
  // Your config
};

If the deprecation error is in a function you can do: (even any defeats purpose of Typescript, is just for locating the problem, to be removed after)

(process as any).traceDeprecation = true;

also can check the value

exports.handler = async (event) => {
    console.log( 'process.traceDeprecation', process.traceDeprecation );
    Buffer(1);
    process.on('warning', (warning) => {
        console.log( 'stack of deprecation' );
        console.log(warning.stack);
    });    
};

Thanks!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.