Skip to content

Commit 11bf3c9

Browse files
committed
Ensure safeMax is safe for undefined values
I came across this when I had a query that threw an error while running for unrelated reasons. At this point, the query results were in a bad state, but this caused `safeMax` to be called with `undefined` and it prevented the extension from starting. This changed fixed the error.
1 parent 8c7c197 commit 11bf3c9

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

extensions/ql-vscode/src/log-insights/join-order.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const DEFAULT_WARNING_THRESHOLD = 50;
77
/**
88
* Like `max`, but returns 0 if no meaningful maximum can be computed.
99
*/
10-
function safeMax(it: Iterable<number>) {
11-
const m = Math.max(...it);
10+
function safeMax(it?: Iterable<number>) {
11+
const m = Math.max(...(it || []));
1212
return Number.isFinite(m) ? m : 0;
1313
}
1414

0 commit comments

Comments
 (0)