Skip to content

Commit

Permalink
fix(chat): simplified error message coming from Cloudflare when using…
Browse files Browse the repository at this point in the history
… a VPN
  • Loading branch information
ichim-david committed Mar 5, 2025
1 parent d1a5d47 commit dae72ad
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions vscode/src/completions/nodeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,29 @@ export class SourcegraphNodeCompletionsClient extends SourcegraphCompletionsClie
})

res.on('error', e => handleError(e))
res.on('end', () =>
handleError(
res.on('end', () => {
const errorOptions = {
url: url.toString(),
status: statusCode,
statusText: res.statusMessage ?? '',
}
let outputMessage = errorMessage

if (statusCode === 403 && res.headers.server === 'cloudflare') {
outputMessage = `Cloudflare has blocked this request.
This may be due to using a VPN or other non-trusted network deemed dangerous.
Please try again without using such an network.
Cloudflare Ray ID: ${res.headers['cf-ray']}`
errorOptions.url = 'Sourcegraph'
}
return handleError(
new NetworkError(
{
url: url.toString(),
status: statusCode,
statusText: res.statusMessage ?? '',
},
errorMessage,
errorOptions,
outputMessage,
getActiveTraceAndSpanId()?.traceId
)
)
)
})
return
}

Expand Down

0 comments on commit dae72ad

Please sign in to comment.