Skip to content

Commit

Permalink
fix: Do not pass numeric arguments to res.send (#242)
Browse files Browse the repository at this point in the history
Fixes #239.

res.send when receiving a sole numeric argument will set thee statuc code to that number.

This breaks HTTP communication as some numbers are not valid HTTP response codes.

For example, in the original issue the code is being set to 2. Which probably comes from the UNKNOWN error response of an RPC call.

This makes that the function is reported as having a `connection error`.
  • Loading branch information
sk- committed Jan 29, 2021
1 parent 3458774 commit a8ace7b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function sendCrashResponse({
// execution sends the response between the check and 'send' call below.
if (res && !res.headersSent) {
res.set(FUNCTION_STATUS_HEADER_FIELD, 'crash');
res.send(err.message || err);
res.send((err.message || err) + '');
}
if (callback) {
callback();
Expand Down

0 comments on commit a8ace7b

Please sign in to comment.