Risk Level
HIGH
File
core/src/exchanges/gemini-titan/websocket.ts
Findings
- Line 276:
this.orderBookResolvers.get(symbol)!.push({ resolve, reject }); — assumes symbol key exists in orderBookResolvers; crashes if it does not.
- Line 305:
this.tradeResolvers.get(symbol)!.push({ resolve, reject }); — same pattern on tradeResolvers.
What Happens When It's Wrong
TypeError: Cannot read properties of undefined (reading 'push') — the pending watchOrderBook or watchTrades promise leaks forever (never resolves, never rejects). Any downstream await hangs until the watch timeout fires, giving the user a timeout error rather than a clear bug report.
Suggested Fix
Ensure the key exists before pushing (mirror the guard used in polymarket/websocket.ts):
if (!this.orderBookResolvers.has(symbol)) this.orderBookResolvers.set(symbol, []);
this.orderBookResolvers.get(symbol)!.push({ resolve, reject });
Or use optional chaining with a fallback:
(this.orderBookResolvers.get(symbol) ?? []).push({ resolve, reject });
// but you'd lose the map entry — the has/set guard is safer
Found by automated non-null assertion audit
Risk Level
HIGH
File
core/src/exchanges/gemini-titan/websocket.tsFindings
this.orderBookResolvers.get(symbol)!.push({ resolve, reject });— assumessymbolkey exists inorderBookResolvers; crashes if it does not.this.tradeResolvers.get(symbol)!.push({ resolve, reject });— same pattern ontradeResolvers.What Happens When It's Wrong
TypeError: Cannot read properties of undefined (reading 'push')— the pendingwatchOrderBookorwatchTradespromise leaks forever (never resolves, never rejects). Any downstreamawaithangs until the watch timeout fires, giving the user a timeout error rather than a clear bug report.Suggested Fix
Ensure the key exists before pushing (mirror the guard used in polymarket/websocket.ts):
Or use optional chaining with a fallback:
Found by automated non-null assertion audit