Understanding Error

The following error is showing up in my logs occasionally. I have a basic understanding of the causes of an unknown interaction, and I believe I can TS the issue, but I have no idea what interaction or code is causing it.
I am unsure if I am not getting any additional traces due to how I log unhandled rejections or if there is no more info. But when I google the error, the posts usually contain more stack traces pointing to the offending file. Do you have any tips on making errors like this a bit more usable to help track down the offending code?
Error: Unhandled promise rejection:
at <anonymous> (/home/azureuser/Nibbles/node_modules/@sparkbot/logger-plugin-interface/index.ts:32:9)
caused by: Error: Missing Access
at new DiscordAPIError (/home/azureuser/Nibbles/node_modules/@discordjs/rest/dist/index.js:583:5)
at <anonymous> (/home/azureuser/Nibbles/node_modules/@discordjs/rest/dist/index.js:730:17)
at processTicksAndRejections (:12:39)
Error: Unhandled promise rejection:
at <anonymous> (/home/azureuser/Nibbles/node_modules/@sparkbot/logger-plugin-interface/index.ts:32:9)
caused by: Error: Missing Access
at new DiscordAPIError (/home/azureuser/Nibbles/node_modules/@discordjs/rest/dist/index.js:583:5)
at <anonymous> (/home/azureuser/Nibbles/node_modules/@discordjs/rest/dist/index.js:730:17)
at processTicksAndRejections (:12:39)
3 Replies
d.js toolkit
d.js toolkit•2mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - ✅ Marked as resolved by OP
Mark
Mark•2mo ago
How do you log the error? You should definitely be able to get more information
Princess Bri Bri 🦄 🌈
I am using pino and this ....
process.on('unhandledRejection', (error) => {
client.logger.error(
new Error('Unhandled promise rejection:', { cause: error }),
);
process.exit(1);
});
process.on('unhandledRejection', (error) => {
client.logger.error(
new Error('Unhandled promise rejection:', { cause: error }),
);
process.exit(1);
});
I just noticed that the one in my orginial post is missing access error, which is really self explanitory, but again no trace. Here is an unkown interaction.
Error: Unhandled promise rejection:
at <anonymous> (/home/azureuser/Nibbles/node_modules/@sparkbot/logger-plugin-interface/index.ts:32:9)
caused by: Error: Unknown interaction
at new DiscordAPIError (/home/azureuser/Nibbles/node_modules/@discordjs/rest/dist/index.js:583:5)
at <anonymous> (/home/azureuser/Nibbles/node_modules/@discordjs/rest/dist/index.js:730:17)
at processTicksAndRejections (:12:39)
Error: Unhandled promise rejection:
at <anonymous> (/home/azureuser/Nibbles/node_modules/@sparkbot/logger-plugin-interface/index.ts:32:9)
caused by: Error: Unknown interaction
at new DiscordAPIError (/home/azureuser/Nibbles/node_modules/@discordjs/rest/dist/index.js:583:5)
at <anonymous> (/home/azureuser/Nibbles/node_modules/@discordjs/rest/dist/index.js:730:17)
at processTicksAndRejections (:12:39)
The only thing I can figgure out is that somewhere in the logging setup, whether it is the unhandled handler or perhaps becuase I am doing that process.on inside a plugin package, or whatever. Just to confirm...there should be more to this error stack correct? As long as I know that, then I know that I need to go dig into my logging setup. So thank you for getting me going in the direction i needed with one question 😄 If I change to this
process.on('unhandledRejection', (error) => {
this.logger.error(error);
});
process.on('unhandledRejection', (error) => {
this.logger.error(error);
});
I get the extra stack trace. So this now gets into the realm of still learning, and if I need to go ask in another server I will, but if I want to wrap the error so that it logs as "Unhandled rejection", what do I need to do to ensure all the trace stays? For reference so you do not have to go back through everything, here is my current code, that does not work.
process.on('unhandledRejection', (error) => {
client.logger.error(
new Error('Unhandled promise rejection:', { cause: error }),
);
});
process.on('unhandledRejection', (error) => {
client.logger.error(
new Error('Unhandled promise rejection:', { cause: error }),
);
});

Did you find this page helpful?