Skip to content

Commit

Permalink
fix that empty message following timeout message (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
fishshi authored Nov 17, 2024
1 parent db44646 commit c792f1e
Showing 1 changed file with 5 additions and 8 deletions.
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

0 comments on commit c792f1e

Please sign in to comment.