Skip to content

Commit 71276ca

Browse files
committed
fix: remove stack trace leakage for errors
Ticket: WP-7677
1 parent c8e8e04 commit 71276ca

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/shared/responseHandler.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ export function responseHandler<T extends Config = Config>(fn: ServiceFunction<T
144144
error: 'Internal Server Error',
145145
name: error instanceof Error ? error.name : 'Error',
146146
details: error instanceof Error ? error.message : String(error),
147-
stack: error instanceof Error ? error.stack : undefined,
147+
stack:
148+
process.env.NODE_ENV === 'development' && error instanceof Error
149+
? error.stack
150+
: undefined,
148151
};
149152
logger.error(JSON.stringify(errorBody, null, 2));
150153
return res.sendEncoded(500, errorBody);

0 commit comments

Comments
 (0)