AutocompleteInteraction#respond takes a long time to return

my code:
const i = Math.random();
console.time(`searching-${i}`);
const focusedValue = interaction.options.getFocused();
const colorDataCopy = [...COLOR_DATA];
// slice limits the options to only be 25
const results = search(colorDataCopy.map((v) => v.name), focusedValue).slice(0, 25).map((v) => ({ name: v, value: v }));
console.timeEnd(`searching-${i}`);
console.time(`responding-${i}`);
try {
await interaction.respond(results);
} catch {
console.log("error occurred");
}
console.timeEnd(`responding-${i}`);
const i = Math.random();
console.time(`searching-${i}`);
const focusedValue = interaction.options.getFocused();
const colorDataCopy = [...COLOR_DATA];
// slice limits the options to only be 25
const results = search(colorDataCopy.map((v) => v.name), focusedValue).slice(0, 25).map((v) => ({ name: v, value: v }));
console.timeEnd(`searching-${i}`);
console.time(`responding-${i}`);
try {
await interaction.respond(results);
} catch {
console.log("error occurred");
}
console.timeEnd(`responding-${i}`);
and the output:
searching-0.22228686743632897: 1.964ms
error occurred
responding-0.22228686743632897: 48.443s
searching-0.22228686743632897: 1.964ms
error occurred
responding-0.22228686743632897: 48.443s
This means that just calling AutocompleteInteraction#respond is taking around 50 seconds to complete. The error is from the interaction taking longer than 3 seconds. I have quite limited memory available (512mb). What could the problem be and how can I fix it?
12 Replies
d.js toolkit
d.js toolkit11mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Post the full error stack trace, not just the top part! - Show your code! - Explain what exactly your issue is. - Not a discord.js issue? Check out #useful-servers. - Issue solved? Press the button!
jackssrt
jackssrt11mo ago
If it matters the command is also only deployed to the current guild, and not globally.
Булочка | pasha_boez
@jackssrt can u console.log the error in try...catch and send output here?
jackssrt
jackssrt11mo ago
searching-0.5178269327384368: 0.473ms
error occurred
Unknown interaction
at handleErrors (node_modules/@discordjs/rest/dist/index.js:640:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async BurstHandler.runRequest (node_modules/@discordjs/rest/dist/index.js:736:23)
at async REST.request (node_modules/@discordjs/rest/dist/index.js:1387:22)
at async AutocompleteInteraction.respond (node_modules/discord.js/src/structures/AutocompleteInteraction.js:86:5)
at async Object.autocomplete (build/commands/color.js:74:4)
at async Client.<anonymous> (build/client.js:224:13)
responding-0.5178269327384368: 15.505s
searching-0.5178269327384368: 0.473ms
error occurred
Unknown interaction
at handleErrors (node_modules/@discordjs/rest/dist/index.js:640:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async BurstHandler.runRequest (node_modules/@discordjs/rest/dist/index.js:736:23)
at async REST.request (node_modules/@discordjs/rest/dist/index.js:1387:22)
at async AutocompleteInteraction.respond (node_modules/discord.js/src/structures/AutocompleteInteraction.js:86:5)
at async Object.autocomplete (build/commands/color.js:74:4)
at async Client.<anonymous> (build/client.js:224:13)
responding-0.5178269327384368: 15.505s
Булочка | pasha_boez
Maybe your internet connection has long ping? Only that request to dsicord API takes a long time, or some other?
d.js docs
d.js docs11mo ago
Please add the following code to your code base outside of any other event listeners and provide the full log output relevant to your issue.
client
.on("debug", console.log)
.on("warn", console.log)
client
.on("debug", console.log)
.on("warn", console.log)
- Note: if you initialize your Client as bot or other identifiers you need to use these instead of client - If the output is too long to post consider using a bin instead: gist | paste.gg | sourceb.in | hastebin
jackssrt
jackssrt11mo ago
Hastebin
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
jackssrt
jackssrt11mo ago
ive seen the time to respond go from like 6 seconds to now 2 minutes, it varies a lot
jackssrt
jackssrt11mo ago
actually if you need to see more logs from when it starts: https://hastebin.com/share/teromurusa.csharp
Hastebin
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
jackssrt
jackssrt11mo ago
respond-${i} is only timing interaction.respond, so only to the discord API
jackssrt
jackssrt11mo ago
Hastebin
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Hastebin
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
jackssrt
jackssrt11mo ago
I am running the bot on replit so there is probably some firewall or proxy Alright, I will look into it...