Skip to content

Commit 4cc210a

Browse files
committed
fix: improve resiliency for requests not going through our infra
1 parent 70d66e7 commit 4cc210a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/telemetry/requestLogger.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ function finishLog<SLocals extends AnyServiceLocals = ServiceLocals<Configuratio
6565
return;
6666
}
6767

68-
const prefs = (res.locals as WithLogPrefs)[LOG_PREFS];
69-
if (prefs?.logged) {
68+
const prefs = (res.locals as WithLogPrefs)[LOG_PREFS] || {};
69+
if (prefs.logged) {
7070
// This happens when error handler runs, but onEnd hasn't fired yet. We only log the first one.
7171
return;
7272
}
7373

7474
const { logger, service } = app.locals;
7575

7676
let dur = 0;
77-
if (prefs?.start) {
77+
if (prefs.start) {
7878
const hrdur = process.hrtime(prefs.start);
7979
dur = hrdur[0] + hrdur[1] / 1000000000;
8080
}

0 commit comments

Comments
 (0)