Skip to content

Commit 42630bd

Browse files
committed
ts fixes
1 parent a11014e commit 42630bd

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/telemetry/requestLogger.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ interface WithLogPrefs {
2424
[LOG_PREFS]: LogPrefs;
2525
}
2626

27+
interface WithFinishedSemaphore {
28+
[SUCCESS_SEMAPHORE]?: true;
29+
}
30+
2731
interface WithIdentifiedSession {
2832
session?: {
2933
id?: string;
@@ -59,7 +63,7 @@ function finishLog<SLocals extends AnyServiceLocals = ServiceLocals<Configuratio
5963
app: ServiceExpress<SLocals>,
6064
error: Error | undefined,
6165
req: Request,
62-
res: Response & { [LOGGED_SEMAPHORE]?: boolean },
66+
res: Response & { [LOGGED_SEMAPHORE]?: boolean } & WithFinishedSemaphore,
6367
histogram: Histogram,
6468
) {
6569
if (res[LOGGED_SEMAPHORE]) {
@@ -83,7 +87,6 @@ function finishLog<SLocals extends AnyServiceLocals = ServiceLocals<Configuratio
8387

8488
let responseType = 'unknown';
8589

86-
// ts warning is known and incorrect—`aborted` is a subset of `destroyed`
8790
if (res[SUCCESS_SEMAPHORE]) {
8891
responseType = 'finished';
8992
} else if (req.aborted) {
@@ -208,7 +211,7 @@ export function loggerMiddleware<
208211

209212
const logWriter = (err?: Error) => finishLog(app, err, req, res, histogram);
210213
res.on('finish', () => {
211-
res[SUCCESS_SEMAPHORE] = true;
214+
(res as Response & WithFinishedSemaphore)[SUCCESS_SEMAPHORE] = true;
212215
logWriter();
213216
});
214217
res.on('close', logWriter);

0 commit comments

Comments
 (0)