Skip to content
Snippets Groups Projects
Commit ef796498 authored by timothycarambat's avatar timothycarambat
Browse files

improve ms-sse-fetch to not re-fetch automatially

parent 79cdb863
No related branches found
No related tags found
No related merge requests found
......@@ -66,6 +66,7 @@ const Workspace = {
body: JSON.stringify({ message, mode }),
headers: baseHeaders(),
signal: ctrl.signal,
openWhenHidden: true,
async onopen(response) {
if (response.ok) {
return; // everything's good
......@@ -74,8 +75,26 @@ const Workspace = {
response.status < 500 &&
response.status !== 429
) {
handleChat({
id: v4(),
type: "abort",
textResponse: null,
sources: [],
close: true,
error: `An error occurred while streaming response. Code ${response.status}`,
});
ctrl.abort();
throw new Error("Invalid Status code response.");
} else {
handleChat({
id: v4(),
type: "abort",
textResponse: null,
sources: [],
close: true,
error: `An error occurred while streaming response. Unknown Error.`,
});
ctrl.abort();
throw new Error("Unknown error");
}
},
......@@ -95,6 +114,7 @@ const Workspace = {
error: `An error occurred while streaming response. ${err.message}`,
});
ctrl.abort();
throw new Error();
},
});
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment