RequestError:错误:当节点版本设置为10x

时间:2019-11-08 07:19:44

标签: node.js aws-lambda

我们正在使用AWS Lambda调用我们的API。我们最近将Lambda节点版本从8.10升级到了节点10.x版本。我们为未处理的拒绝添加了处理事件,并在try-catch块中编写了代码,但是没有代码可以解决我们的问题。请找到通过Lambda调用API时遇到的错误块。

请注意,我们使用的是Promise-request NPM软件包。

尝试使用try捕获并使用Process.event处理未处理事件的代码

 {
  "errorType": "Runtime.UnhandledPromiseRejection",
  "errorMessage": "RequestError: Error: Client network socket disconnected before secure TLS connection was established",
  "stack": [
    "Runtime.UnhandledPromiseRejection: RequestError: Error: Client network socket disconnected before secure TLS connection was established",
    "    at process.on (/var/runtime/index.js:37:15)",
    "    at process.emit (events.js:203:15)",
    "    at process.EventEmitter.emit (domain.js:448:20)",
    "    at /var/task/node_modules/bluebird/js/release/debuggability.js:199:33",
    "    at activeFireEvent (/var/task/node_modules/bluebird/js/release/debuggability.js:242:44)",
    "    at fireRejectionEvent (/var/task/node_modules/bluebird/js/release/debuggability.js:632:14)",
    "    at Promise._notifyUnhandledRejection (/var/task/node_modules/bluebird/js/release/debuggability.js:65:9)",
    "    at Timeout._onTimeout (/var/task/node_modules/bluebird/js/release/debuggability.js:44:14)",
    "    at ontimeout (timers.js:436:11)",
    "    at tryOnTimeout (timers.js:300:5)",
    "    at listOnTimeout (timers.js:263:5)",
    "    at Timer.processTimers (timers.js:223:10)"
  ],
  "reason": {
    "errorType": "RequestError",
    "errorMessage": "Error: Client network socket disconnected before secure TLS connection was established",
    "stack": [
      "RequestError: Error: Client network socket disconnected before secure TLS connection was established",
      "    at new RequestError (/var/task/node_modules/request-promise-core/lib/errors.js:14:15)",
      "    at Request.plumbing.callback (/var/task/node_modules/request-promise-core/lib/plumbing.js:87:29)",
      "    at Request.RP$callback [as _callback] (/var/task/node_modules/request-promise-core/lib/plumbing.js:46:31)",
      "    at self.callback (/var/task/node_modules/request/request.js:185:22)",
      "    at Request.emit (events.js:198:13)",
      "    at Request.EventEmitter.emit (domain.js:448:20)",
      "    at Request.onRequestError (/var/task/node_modules/request/request.js:881:8)",
      "    at ClientRequest.emit (events.js:198:13)",
      "    at ClientRequest.EventEmitter.emit (domain.js:448:20)",
      "    at TLSSocket.socketErrorListener (_http_client.js:392:9)",
      "    at TLSSocket.emit (events.js:198:13)",
      "    at TLSSocket.EventEmitter.emit (domain.js:448:20)",
      "    at emitErrorNT (internal/streams/destroy.js:91:8)",
      "    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)",
      "    at process._tickCallback (internal/process/next_tick.js:63:19)"
    ],
}
}

1 个答案:

答案 0 :(得分:0)

现在可以升级到Node.js 12.x,从而避免了该问题。