add diagnostic logging for WebSocket disconnect and OHLC flow
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -311,8 +311,8 @@ export class WebSocketHandler {
|
||||
});
|
||||
|
||||
// Handle disconnection
|
||||
socket.on('close', async () => {
|
||||
logger.info({ sessionId: authContext.sessionId }, 'WebSocket disconnected');
|
||||
socket.on('close', async (code: number, reason: Buffer) => {
|
||||
logger.info({ sessionId: authContext.sessionId, code, reason: reason?.toString() }, 'WebSocket disconnected');
|
||||
|
||||
// Unregister from event system
|
||||
const removedSession = this.config.sessionRegistry.unregister(authContext.sessionId);
|
||||
@@ -491,6 +491,7 @@ export class WebSocketHandler {
|
||||
payload.to_time,
|
||||
payload.countback
|
||||
);
|
||||
logger.info({ requestId, barCount: history.bars?.length ?? 0, noData: history.noData, socketState: socket.readyState }, 'Sending get_bars_response');
|
||||
socket.send(
|
||||
jsonStringifySafe({
|
||||
type: 'get_bars_response',
|
||||
@@ -498,6 +499,7 @@ export class WebSocketHandler {
|
||||
history,
|
||||
})
|
||||
);
|
||||
logger.info({ requestId }, 'get_bars_response sent');
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -104,14 +104,16 @@ export class OHLCService {
|
||||
end_time
|
||||
);
|
||||
|
||||
this.logger.info({ ticker, period_seconds, dataCount: data.length, missingRangeCount: missingRanges.length, missingRanges }, 'OHLC cache check result');
|
||||
|
||||
if (missingRanges.length === 0 && data.length > 0) {
|
||||
// All data exists in Iceberg
|
||||
this.logger.debug({ ticker, period_seconds, cached: true }, 'OHLC data found in cache');
|
||||
this.logger.info({ ticker, period_seconds, cached: true }, 'OHLC data found in cache, returning immediately');
|
||||
return this.formatHistoryResult(data, start_time, end_time, period_seconds, countback);
|
||||
}
|
||||
|
||||
// Step 3: Request missing data via relay
|
||||
this.logger.debug({ ticker, period_seconds, missingRanges: missingRanges.length }, 'Requesting missing OHLC data');
|
||||
this.logger.info({ ticker, period_seconds, missingRanges: missingRanges.length, dataCount: data.length }, 'Requesting missing OHLC data from relay');
|
||||
|
||||
try {
|
||||
const notification = await this.relayClient.requestHistoricalOHLC(
|
||||
@@ -131,7 +133,9 @@ export class OHLCService {
|
||||
}, 'Historical data request completed');
|
||||
|
||||
// Step 4: Query Iceberg again for complete dataset
|
||||
this.logger.info({ ticker, period_seconds, notification_status: notification.status, row_count: notification.row_count }, 'Relay notification received, re-querying Iceberg');
|
||||
data = await this.icebergClient.queryOHLC(ticker, period_seconds, start_time, end_time);
|
||||
this.logger.info({ ticker, period_seconds, dataCount: data.length }, 'Final Iceberg query complete, returning result');
|
||||
|
||||
return this.formatHistoryResult(data, start_time, end_time, period_seconds, countback);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user