Closed markwylde closed 2 months ago
Doing the following in my entry script does seem to fix the issue:
global.Error = class extends Error {
constructor(message) {
super(message);
this.stack += '';
}
}
Sounds like you didn't set the Error.stackTraceLimit.
Thanks for the response @AndreasMadsen.
I have tried the code below:
require('trace');
require('clarify');
Error.stackTraceLimit = 100000;
const axios = require('axios')
async function main () {
await axios(`https://example.com/xxxxxxxx`)
}
main()
Which outputs the same "error":
(node:6122) UnhandledPromiseRejectionWarning: Error: Request failed with status code 404
at createError (/private/tmp/node_modules/axios/lib/core/createError.js:16:15)
at settle (/private/tmp/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/private/tmp/node_modules/axios/lib/adapters/http.js:236:11)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:6122) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:6122) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I'm trying to use Axios to make http calls and have the following code.
It of course fails with a 404 as expected with absolutely no useful information.
So let's put in
trace
.This still doesn't give us anything useful.
So I looked into the Axios codebase to see what is going on and discovered they have a
createError
function. I edited the following...Note the only thing I changed was effectively running the setter for stack.
error.stack += '';
Again I get nothing. BUT when I install
clarify
I finally get the information I wanted:I need both
clarify
and to touch the.stack
inside Axios to make this work.I don't mind having to keep clarify installed, that's all good and I'd be using it anyway. But obviously touching Axios or any other libraries to touch the
.stack
seems weird.Am I crazy? Is this a bug and known? Is there anything I can do?
Thanks and amazing projects btw.