Error: Expected token to be set for this request, but none was present
I'm seeing this error popup on my bot where I use @djs/rest, I'm not entirely sure why it happens or when it happens, it sort of just happens out of nowhere. My bot functions normally as usual, and then every once in a while this error will popup (I use serverless btw). Here's the full error if it helps:
Error: Expected token to be set for this request, but none was present
at _REST.resolveRequest (/app/node_modules/@discordjs/rest/dist/index.js:1367:15)
at _REST.queueRequest (/app/node_modules/@discordjs/rest/dist/index.js:1327:46)
at _REST.request (/app/node_modules/@discordjs/rest/dist/index.js:1293:33)
at _REST.post (/app/node_modules/@discordjs/rest/dist/index.js:1267:17)
at Object.execute (/app/commands/edit_submission.js:77:28)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async /app/index.js:120:21
Also before you ask yes I updated the package yesterday and it happened again today. I'm also on Node v22.3.0
2 Replies
I'll be reviving this thread since I'm having the sameish issue as far as I noticed. I've got a theory on what's happening since my logs paint a picture:
bun 1.2.13 & @discordjs/rest 2.5.1
The error case only occurs if I request a webhook route with an expired token.
I'm not yet sure if this is actually the case and will be conducting some more thorough tests.
Setting auth to false should fix this issue if I'm guessing correctly. But still the rest client should not completely lock down