Skip to content

Commit

Permalink
fix: possible race condition leading to 404s (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobby-McBobface authored Nov 17, 2024
1 parent c3e268f commit 4d41316
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,12 @@ export abstract class BaseInteraction<T extends BaseInteractionType = BaseIntera
if (response.writableEnded) throw new Error('Cannot send response, the request has already been replied.');

response.statusCode = HttpCodes.OK;
return new Promise<void>((resolve) => response.end(JSON.stringify(data), resolve));
return new Promise<void>((resolve) => {
response.on('close', () => {
resolve();
});
response.end(JSON.stringify(data));
});
}
}

Expand Down

0 comments on commit 4d41316

Please sign in to comment.