Worker with Slash-Up Discord Slash Commands Failing

I am currently using slash-create with Cloudflare Workers to integrate Discord Slash commands. I'm getting the below error when I attempt to add the integration on Discord's side.
A hanging Promise was canceled. This happens when the worker runtime is waiting for a Promise from JavaScript to resolve, but has detected that the Promise cannot possibly ever resolve because all code and events related to the Promise's I/O context have already finished.
āœ˜ [ERROR] Uncaught (in response) Error: The script will never generate a response.
A hanging Promise was canceled. This happens when the worker runtime is waiting for a Promise from JavaScript to resolve, but has detected that the Promise cannot possibly ever resolve because all code and events related to the Promise's I/O context have already finished.
āœ˜ [ERROR] Uncaught (in response) Error: The script will never generate a response.
This all works in local mode, but not on the worker itself (or outside of local mode). I've made some modifications to the boilerplate to get it to run properly. But I never thought to check outside of local mode when I was originally setting up. Happy to share my project if anyone wants to take a look šŸ™‚ Source is here: https://github.com/TristanWiley/procity-slash-commands Relevant code is most likely in src/shim/servers/cfworker.ts and src/shim/creator.ts. This is where I've been looking. Unfortunately this is code I did not write and are a part of the library itself, however probably outdated a bit.
GitHub
GitHub - TristanWiley/procity-slash-commands
Contribute to TristanWiley/procity-slash-commands development by creating an account on GitHub.
8 Replies
sirhype
sirhypeOPā€¢2y ago
Investigated a bit more, looks like this line here is where the last item is being run. So when we get to the handler section that's where we fail Something about the binding probably?
this.server.createEndpoint(this.options.endpointPath as string, this._onRequest.bind(this));
this.server.createEndpoint(this.options.endpointPath as string, this._onRequest.bind(this));
zegevlier
zegevlierā€¢2y ago
How are you testing locally?
zegevlier
zegevlierā€¢2y ago
I've not seeb that library before, but if you're still in the early stages and willing to switch, https://github.com/mrbbot/slshx works really great with workers in my experience
GitHub
GitHub - mrbbot/slshx: āš”ļø Strongly-typed Discord commands on Cloudf...
āš”ļø Strongly-typed Discord commands on Cloudflare Workers - GitHub - mrbbot/slshx: āš”ļø Strongly-typed Discord commands on Cloudflare Workers
zegevlier
zegevlierā€¢2y ago
It feels like the issue is that something is waiting forever on some request and so is triggering that limit. The reason you don't hit that locally is because wrangler uses miniflare for local testing and that merely simulates workers so there are some discrepancies.
sirhype
sirhypeOPā€¢2y ago
Testing locally using wrangler dev and using cloudflared (https://github.com/cloudflare/cloudflared) I definitely could solve this a lot easier by changing libraries (and I honestly probably will). I just know it's going to bug me if I never figure this out, because I'm so curious what is actually happening lul you for the library recommendation though! I'll probably migrate to it tonight šŸ™‚ the bug is not worth my time as curious as I am
zegevlier
zegevlierā€¢2y ago
Yea I totally get that haha. I don't see anything immediately pop out as the cause, but there are a lot of things that could cause an error like this.
sirhype
sirhypeOPā€¢2y ago
Yeah, I'm gonna swap over to the other library now. I mostly was so attached because I spent ages upgrading library and migrating things lul thank you again
sirhype
sirhypeOPā€¢2y ago
I just realized, I had originally tried slshx but disregarded it since it wouldn't work for me. Turns out the issue was just my node version (found here -> https://discord.com/channels/595317990191398933/799437470004412476/1009374662553260093) lul
Discord
Discord - A New Way to Chat with Friends & Communities
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
Want results from more Discord servers?
Add your server