mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Integrate wrapStreamError to prevent uncaught errors
This commit is contained in:
@@ -3,6 +3,7 @@ import cors from 'cors';
|
||||
import type { Express } from 'express';
|
||||
import express from 'express';
|
||||
import { getLoggerFor } from '../logging/LogUtil';
|
||||
import { guardStream } from '../util/GuardedStream';
|
||||
import type { HttpHandler } from './HttpHandler';
|
||||
import type { HttpServerFactory } from './HttpServerFactory';
|
||||
|
||||
@@ -40,7 +41,7 @@ export class ExpressHttpServerFactory implements HttpServerFactory {
|
||||
app.use(async(request, response, done): Promise<void> => {
|
||||
try {
|
||||
this.logger.info(`Received request for ${request.url}`);
|
||||
await this.handler.handleSafe({ request, response });
|
||||
await this.handler.handleSafe({ request: guardStream(request), response });
|
||||
} catch (error: unknown) {
|
||||
const errMsg = error instanceof Error ? `${error.name}: ${error.message}\n${error.stack}` : 'Unknown error.';
|
||||
this.logger.error(errMsg);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { IncomingMessage } from 'http';
|
||||
import type { Guarded } from '../util/GuardedStream';
|
||||
|
||||
/**
|
||||
* An incoming HTTP request;
|
||||
*/
|
||||
export type HttpRequest = IncomingMessage;
|
||||
export type HttpRequest = Guarded<IncomingMessage>;
|
||||
|
||||
Reference in New Issue
Block a user