Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/driver/express/ExpressDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ export class ExpressDriver extends BaseDriver {
* Handles result of successfully executed controller action.
*/
handleSuccess(result: any, action: ActionMetadata, options: Action): void {
if (options && options.response && options.response.headersSent) {
console.warn('Response headers were already sent, default handleSuccess will not be executed.');
options.next();
return;
}
// if the action returned the response object itself, short-circuits
if (result && result === options.response) {
options.next();
Expand Down Expand Up @@ -354,6 +359,11 @@ export class ExpressDriver extends BaseDriver {
* Handles result of failed executed controller action.
*/
handleError(error: any, action: ActionMetadata | undefined, options: Action): any {
if (options && options.response && options.response.headersSent) {
console.warn('Response headers were already sent, default handleError will not be executed.');
options.next(error);
return;
}
if (this.isDefaultErrorHandlingEnabled) {
const response: any = options.response;

Expand Down