Skip to content

Commit 53da28d

Browse files
alexmarqsjpinho
andauthored
Update packages/large-response-middleware/src/index.ts
Co-authored-by: João Pinho <[email protected]>
1 parent 57862b0 commit 53da28d

File tree

1 file changed

+5
-6
lines changed
  • packages/large-response-middleware/src

1 file changed

+5
-6
lines changed

packages/large-response-middleware/src/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,14 @@ export const withLargeResponseHandler = ({
103103
response_size_mb: contentLengthMB.toFixed(2),
104104
$payload_ref,
105105
});
106-
107106
response.isBase64Encoded = false;
108107
response.statusCode = 413;
108+
const responseErrorMessage = customErrorMessage ?? LARGE_RESPONSE_USER_INFO;
109+
109110
response.body = JSON.stringify({
110-
message: customErrorMessage
111-
? typeof customErrorMessage === 'string'
112-
? customErrorMessage
113-
: customErrorMessage(event)
114-
: LARGE_RESPONSE_USER_INFO,
111+
message: typeof responseErrorMessage === 'string'
112+
? responseErrorMessage
113+
: customErrorMessage?.(event) || customErrorMessage,
115114
});
116115
}
117116
} else if (contentLengthMB > thresholdWarnInMB) {

0 commit comments

Comments
 (0)