Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[logging] Corrects intercept of ECONNRESET #31742

Merged
merged 4 commits into from
Feb 23, 2019
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions src/legacy/server/logging/log_interceptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ function doesMessageMatch(errorMessage, match) {
if (isRegExp) return match.test(errorMessage);
return errorMessage === match;
}

// converts the given event into a debug log if it's an error of the given type
function downgradeIfErrorType(errorType, event, field = 'errno') {
function downgradeIfErrorType(errorType, event) {
const isClientError = doTagsMatch(event, ['connection', 'client', 'error']);
const matchesErrorType = isClientError && get(event, `error.${field}`) === errorType;
if (!isClientError) return null;

const matchesErrorType = get(event, 'error.code') === errorType || get(event, 'error.errno') === errorType;
if (!matchesErrorType) return null;

const errorTypeTag = errorType.toLowerCase();
Expand Down Expand Up @@ -117,7 +119,7 @@ export class LogInterceptor extends Stream.Transform {
}

downgradeIfHTTPSWhenHTTP(event) {
return downgradeIfErrorType('HPE_INVALID_METHOD', event, 'code');
return downgradeIfErrorType('HPE_INVALID_METHOD', event);
}

downgradeIfHTTPWhenHTTPS(event) {
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/server/logging/log_interceptor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function stubClientErrorEvent(errorMeta) {
};
}

const stubEconnresetEvent = () => stubClientErrorEvent({ errno: 'ECONNRESET' });
const stubEconnresetEvent = () => stubClientErrorEvent({ code: 'ECONNRESET' });
const stubEpipeEvent = () => stubClientErrorEvent({ errno: 'EPIPE' });
const stubEcanceledEvent = () => stubClientErrorEvent({ errno: 'ECANCELED' });

Expand Down