Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Error when using http or https lib on node 14.x #563

Copy link
Copy link
@melvinvdb

Description

@melvinvdb
Issue body actions

Hi,

When using the node https lib with options the following error occurs:

/usr/local/lib/node_modules/node-lambda/node_modules/continuation-local-storage/context.js:55
    throw exception;
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received an instance of Object
    at checkListener (events.js:112:11)
    at ClientRequest.once (events.js:435:3)
    at new ClientRequest (_http_client.js:202:10)
    at Object.request (https.js:313:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/node-lambda/node_modules/agent-base/patch-core.js:25:22)
    at Object.request (/usr/local/lib/node_modules/node-lambda/node_modules/socks-proxy-agent/node_modules/agent-base/patch-core.js:23:20)
    at Object.https.get (/usr/local/lib/node_modules/node-lambda/node_modules/socks-proxy-agent/node_modules/agent-base/patch-core.js:34:21)
    at exports.handler (/Users/melvinvandenberg/Downloads/index.js:7:20)
    at /usr/local/lib/node_modules/node-lambda/lib/main.js:130:22
    at Namespace.run (/usr/local/lib/node_modules/node-lambda/node_modules/continuation-local-storage/context.js:48:5) {
  code: 'ERR_INVALID_ARG_TYPE',
  'error@context': [Object: null prototype] {
    segment: Segment {
      trace_id: '1-60817b33-a937e1cf99a50c3fc64ff771',
      id: '944ec65459aed4bf',
      start_time: 1619098419.324,
      name: 'annotations',
      in_progress: true,
      counter: 0,
      service: {
        runtime: 'node',
        runtime_version: 'v14.16.1',
        version: 'unknown',
        name: 'unknown'
      },
      aws: {
        xray: {
          sdk: 'X-Ray for Node.js',
          sdk_version: '3.3.1',
          package: 'aws-xray-sdk-core'
        }
      }
    }
  }
}

Full sample code:

var https = require('https');

exports.handler = (event, context, callback) => {
	const options = {
		timeout: 20000
	};
	const req = https.get("https://webhook.site/3b11d000-453d-494a-994e-d28839de1ce8", options, res => {
		console.log(res.statusCode);
	})

}

When hacking into node-lambda and updating "proxy-agent": "^3.1.1" to "proxy-agent": "^4.0.1" the problem is solved.
See issues: TooTallNate/node-agent-base#29 and another project that had this issue: microsoft/vscode#93167.

Could someone update the proxy-agent dep? Thanks!

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.