[fix] meaningless stream.cancel()
This commit is contained in:
@@ -418,13 +418,16 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const close = () => {
|
||||||
|
oobaboogaSocket.close()
|
||||||
|
}
|
||||||
const stream = new ReadableStream({
|
const stream = new ReadableStream({
|
||||||
start(controller){
|
start(controller){
|
||||||
let readed = "";
|
let readed = "";
|
||||||
oobaboogaSocket.onmessage = async (event) => {
|
oobaboogaSocket.onmessage = async (event) => {
|
||||||
const json = JSON.parse(event.data);
|
const json = JSON.parse(event.data);
|
||||||
if (json.event === "stream_end") {
|
if (json.event === "stream_end") {
|
||||||
oobaboogaSocket.close()
|
close()
|
||||||
controller.close()
|
controller.close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -435,13 +438,12 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
oobaboogaSocket.send(JSON.stringify(bodyTemplate));
|
oobaboogaSocket.send(JSON.stringify(bodyTemplate));
|
||||||
},
|
},
|
||||||
cancel(){
|
cancel(){
|
||||||
oobaboogaSocket.close()
|
close()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const cancel = () => stream.cancel()
|
oobaboogaSocket.onerror = close
|
||||||
oobaboogaSocket.onerror = cancel
|
oobaboogaSocket.onclose = close
|
||||||
oobaboogaSocket.onclose = cancel
|
abortSignal.addEventListener("abort", close)
|
||||||
abortSignal.addEventListener("abort", cancel)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: 'streaming',
|
type: 'streaming',
|
||||||
|
|||||||
Reference in New Issue
Block a user