Issue with using a proxy

When running a slash command, I've observed an error at the following line: await interaction.deferReply({ephemeral}); Error:
TypeError: Cannot read properties of null (reading 'startsWith')
at parseResponse (/node_modules/discord.js/src/rest/RequestHandler.js:14:38)
at RequestHandler.execute (/node_modules/discord.js/src/rest/RequestHandler.js:302:14)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
at async CommandInteraction.deferReply (/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:61:5)
at Object.run (/src/commandsSlash/miscellaneous/ping.ts:22:9)
at Client.interactionCreate (/src/events/interactionCreate.ts:80:17)
TypeError: Cannot read properties of null (reading 'startsWith')
at parseResponse (/node_modules/discord.js/src/rest/RequestHandler.js:14:38)
at RequestHandler.execute (/node_modules/discord.js/src/rest/RequestHandler.js:302:14)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
at async CommandInteraction.deferReply (/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:61:5)
at Object.run (/src/commandsSlash/miscellaneous/ping.ts:22:9)
at Client.interactionCreate (/src/events/interactionCreate.ts:80:17)
I'm proxying all discord requests through a proxy and I have 2 proxies available, one works, one doesn't. The differences between the two are: Working proxy: HTTP only, not HTTPS (Slightly modified djs for this to allow http proxies to work) direct ip:port -> proxy Failing proxy: Forced HTTPS + HSTS (Modifications removed as https proxies are supported out of the box) Domain name -> Cloudflare (+ WAF) -> nginx -> proxy Normal commands work perfectly fine, this error only occurs on interaction.deferReply() and probably other interaction related requests as well, however I havent tested that aside from deferReply
8 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Sammy
Sammy2y ago
Node is v18.12.1 and Discord.js is v13.13.1, same issue occurs on v13.12.0 v14 seems to have fixed this?
export async function parseResponse(res: Dispatcher.ResponseData): Promise<unknown> {
const header = parseHeader(res.headers['content-type']);
if (header?.startsWith('application/json')) {
return res.body.json();
}

return res.body.arrayBuffer();
}
export async function parseResponse(res: Dispatcher.ResponseData): Promise<unknown> {
const header = parseHeader(res.headers['content-type']);
if (header?.startsWith('application/json')) {
return res.body.json();
}

return res.body.arrayBuffer();
}
At least thats what i found on github, seems there the possibility of headers being null is taken into account, how come this isnt the case on v13? Should i apply a patch for this manually or
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Sammy
Sammy2y ago
Yeah id like an actual fix on v13 i dont have the time to update to 14 rn
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Sammy
Sammy2y ago
Anyone able to help me with this?
Sammy
Sammy2y ago
Sure about that?
Sammy
Sammy2y ago
Seeing as the error im having seems(?) to have been fixed in v14, and v13 is still being supported, i think a backport of that fix would be reasonable Seems that a single ? in discord.js fixed the issue, will be testing it a little more extensively later tonight i guess ill open a pr if i dont encounter any other issues
Want results from more Discord servers?
Add your server