Skip to content

Commit 365670c

Browse files
committed
refactor: SonarCube didn't like it
1 parent ca5e7c7 commit 365670c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/telemetry/requestLogger.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,22 @@ function finishLog<SLocals extends AnyServiceLocals = ServiceLocals<Configuratio
7676

7777
const dur = hrdur[0] + hrdur[1] / 1000000000;
7878
const [url, preInfo] = getBasicInfo(req);
79+
80+
let responseType: string = 'finished';
81+
82+
// ts warning is known and incorrect—`aborted` is a subset of `destroyed`
83+
if (req.aborted) {
84+
responseType = 'aborted';
85+
} else if (req.destroyed) {
86+
responseType = 'destroyed';
87+
} else if (error) {
88+
responseType = 'errored';
89+
}
90+
7991
const endLog: Record<string, string | string[] | number | undefined> = {
8092
...preInfo,
8193
t: 'req',
82-
// ts warning is known and incorrect—`aborted` is a subset of `destroyed``
83-
r: req.aborted ? 'aborted' : req.destroyed ? 'destroyed' : error ? 'errored' : 'finished',
94+
r: responseType,
8495
s: (error as ErrorWithStatus)?.status || res.statusCode || 0,
8596
dur,
8697
};

0 commit comments

Comments
 (0)