feat: 请求失败关闭sse
This commit is contained in:
@ -70,15 +70,14 @@ export default async (config: SSEConfig, url: string = DEFAULT_SSE_URL): Promise
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onerror(error: Error) {
|
onerror(error: Error) {
|
||||||
// console.error('SSE error:', error);
|
// 请求失败时主动关闭SSE连接
|
||||||
|
abortController.abort();
|
||||||
handleError?.(error);
|
handleError?.(error);
|
||||||
},
|
},
|
||||||
onclose() {
|
onclose() {
|
||||||
// console.log('SSE connection closed');
|
|
||||||
handleClose?.();
|
handleClose?.();
|
||||||
},
|
},
|
||||||
async onopen(response: Response) {
|
async onopen(response: Response) {
|
||||||
// console.log('onopen', response);
|
|
||||||
handleOpen?.(response);
|
handleOpen?.(response);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user