gpt4 book ai didi

node.js - 如何从nodejs请求捕获像MaxListenersExceededWarning这样的错误?

转载 作者:太空宇宙 更新时间:2023-11-03 23:21:24 33 4
gpt4 key购买 nike

例如,以下错误不会被请求的常规 try/catch 捕获:

(node:6432) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 pipe listeners added. Use emitter.setMaxListeners() to increase limit
Error: Exceeded maxRedirects. Probably stuck in a redirect loop https://9.20.65.117/
at Redirect.onResponse (/XXX/node_modules/request/lib/redirect.js:98:27)
at Request.onRequestResponse (/XXX/node_modules/request/request.js:990:22)
at emitOne (events.js:115:13)
at ClientRequest.emit (events.js:210:7)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:565:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:116:23)
at TLSSocket.socketOnData (_http_client.js:454:20)
at emitOne (events.js:115:13)
at TLSSocket.emit (events.js:210:7)
at addChunk (_stream_readable.js:266:12)

最佳答案

您可以简单地在请求选项对象中禁用遵循 3xx 重定向请求({followRedirect: false}, ...)

或者将 Nodejs process.setMaxListeners(0); 更改为 0(无限制)

关于node.js - 如何从nodejs请求捕获像MaxListenersExceededWarning这样的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49302921/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com