Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix that empty message following timeout message #402

Merged
merged 1 commit into from
Nov 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/extension/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,8 @@ export async function streamResponse(request: StreamRequest) {
const { signal } = controller

const timeOut = setTimeout(() => {
controller.abort()
onError?.(new Error("Request timed out"))
log.logConsoleError(
Logger.ErrorType.Timeout,
"Failed to establish connection",
new Error("Request timed out")
)
}, 25000)
controller.abort(new DOMException("Request timed out", "TimeoutError"))
}, 60000)

try {
const url = `${options.protocol}://${options.hostname}${
Expand Down Expand Up @@ -102,6 +96,9 @@ export async function streamResponse(request: StreamRequest) {
if (error instanceof Error) {
if (error.name === "AbortError") {
onEnd?.()
} else if (error.name === "TimeoutError") {
onError?.(error)
log.logConsoleError(Logger.ErrorType.Timeout, "Failed to establish connection", error)
} else {
log.logConsoleError(Logger.ErrorType.Fetch_Error, "Fetch error", error)
onError?.(error)
Expand Down