Add async to the handleRequest chain in HttpServer (!387)
The httpListeners are promise based but they aren't awaited when handling the request. I found this while implementing another version of HttpServer in a mod but couldn't actually find where this would cause an issue so feel free to close this if you think it's not worth it. Reviewed-on: https://dev.sp-tarkov.com/SPT/Server/pulls/387 Co-authored-by: RomanxTheLast <alex@romanx.co.uk> Co-committed-by: RomanxTheLast <alex@romanx.co.uk>
This commit is contained in:
parent
45e559efff
commit
398bf43444
@ -39,8 +39,8 @@ export class HttpServer {
|
||||
/* create server */
|
||||
const httpServer: Server = http.createServer();
|
||||
|
||||
httpServer.on("request", (req, res) => {
|
||||
this.handleRequest(req, res);
|
||||
httpServer.on("request", async (req, res) => {
|
||||
await this.handleRequest(req, res);
|
||||
});
|
||||
|
||||
/* Config server to listen on a port */
|
||||
@ -65,7 +65,7 @@ export class HttpServer {
|
||||
this.webSocketServer.setupWebSocket(httpServer);
|
||||
}
|
||||
|
||||
protected handleRequest(req: IncomingMessage, resp: ServerResponse): void {
|
||||
protected async handleRequest(req: IncomingMessage, resp: ServerResponse): Promise<void> {
|
||||
// Pull sessionId out of cookies and store inside app context
|
||||
const sessionId = this.getCookies(req).PHPSESSID;
|
||||
this.applicationContext.addValue(ContextVariableType.SESSION_ID, sessionId);
|
||||
@ -93,7 +93,7 @@ export class HttpServer {
|
||||
|
||||
for (const listener of this.httpListeners) {
|
||||
if (listener.canHandle(sessionId, req)) {
|
||||
listener.handle(sessionId, req, resp);
|
||||
await listener.handle(sessionId, req, resp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user