NODE_OPTIONS='--insecure-http-parser' not being used with AWS Lambda

Viewed 856

One of the web services my lambda connects to is periodically returning an invalid HTTP header and causing Node to throw with this error.

We are running lambda with the NodeJS 12.x runtime.

"name": "RequestError",
    "message": "Error: Parse Error: Invalid header value char",
    "cause": {
        "bytesParsed": ,
        "code": "HPE_INVALID_HEADER_TOKEN",
        ....

Following the instructions from this link it looks like the fix for 12.X would be to either use --insecure-http-parser or --http-parser=legacy as an option to starting Node.

Passing insecureHTTPParser to http.request() is not an option since we are using a http abstraction.

On Lambda the documented way to pass CLI options to use is to use the NODE_OPTIONS environment variable which is documented here

So I've tried setting either --insecure-http-parser or --http-parser=legacy and spawning a new lambda invocation and I'm still getting the HPE_INVALID_HEADER_TOKEN error.

Here's a screenshot of my Environment Variables in lambda.

env variables

Upgrading the NodeJS runtime is not an option too.

My high level question is how can I make this work?

Some other useful information in the comments would be

  1. How can I verify that NODE_OPTIONS passed to Lambda in an environment variable are actually set at runtime?
  2. How can I verify what HTTP parser is configured to be used in Node 12.x?
0 Answers
Related