Skip to content

Commit

Permalink
on empty chat streaming response, log span and trace id (#5439)
Browse files Browse the repository at this point in the history
  • Loading branch information
beyang authored Sep 2, 2024
1 parent f8a1b72 commit f7d6cbf
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions vscode/src/completions/nodeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,30 @@ export class SourcegraphNodeCompletionsClient extends SourcegraphCompletionsClie
//
// We still want to close the request.
request.on('close', () => {
const traceSpan = getActiveTraceAndSpanId()
const traceInfo = traceSpan
? { traceId: traceSpan.traceId, spanId: traceSpan.spanId }
: undefined
if (!didReceiveAnyEvent) {
logError(
'SourcegraphNodeCompletionsClient',
"request.on('close')",
'Connection closed without receiving any events',
'Connection closed without receiving any events (this may be due to an outage with the upstream LLM provider)',
`trace-and-span: ${JSON.stringify(traceInfo)}`,
{ verbose: { bufferText } }
)
onErrorOnce(new Error('Connection closed without receiving any events'))
onErrorOnce(
new Error(
`Connection closed without receiving any events (this may be due to an outage with the upstream LLM provider) ${JSON.stringify(
traceInfo
)}`
)
)
}
if (!didSendMessage) {
onErrorOnce(new Error('Connection unexpectedly closed'))
onErrorOnce(
new Error(`Connection unexpectedly closed: ${JSON.stringify(traceInfo)}`)
)
}
})

Expand Down

0 comments on commit f7d6cbf

Please sign in to comment.