Error: toString failed Node.js buffer

混江龙づ霸主 提交于 2019-12-22 10:48:22

问题


Sometimes my get request to an api fails with this error message, (btw im using the request module to trigger my requests)

Error: toString failed
buffer.js:378
    throw new Error('toString failed');
    ^

Error: toString failed
    at Buffer.toString (buffer.js:378:11)
    at BufferList.toString (/home/vardha/www/abp/node_modules/bl/bl.js:155:33)
    at Request.<anonymous> (/home/vardha/www/abp/node_modules/request/request.js:1013:32)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (/home/vardha/www/abp/node_modules/request/request.js:962:12)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:921:12)
    at nextTickCallbackWith2Args (node.js:442:9)

This has been buggin me a lot since I have no idea as to whats causing this and was not able to find any clear solution in the github page. ANy help would be appreciated.


回答1:


This error usually occurs when you request for file which is relatively bigger in size (or) the bufferlength exceeds / reaches 256 MB which the V8 engine will throw as an error.

This issue is still being addressed by the NodeJS community Read out this comprehensive post which has all the progress/answers that you are looking for.

https://github.com/nodejs/node/pull/4394

Hope this helps!



来源:https://stackoverflow.com/questions/40382268/error-tostring-failed-node-js-buffer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!