-
Notifications
You must be signed in to change notification settings - Fork 146
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
Can it be achieved to interrupt or cancel the response during the response process #62
Comments
Do you mean cancelling an active request from the client? If so, you can provide a |
You don't happen to have an example of this working by any chance? I understand that this is default fetch functionality that is supposedly not impacted by this library, but for me, providing the
|
It was pretty straight forward for me. My actual code is too complicated for a simple example but it boils down to something like: const abortController = new AbortController()
fetchEventSource(someUrl, {
signal: abortController.signal,
onmessage(ev) {
const data = JSON.parse(ev.data) as MyData;
console.log(data);
},
})
abortController.abort(); // this should cancel & close your request If you're using React.js or similar, make sure you've got the same |
中断需要你在 onmessage(){ if(needStop){throw Error()} } |
Can it be achieved to interrupt or cancel the response during the response process
The text was updated successfully, but these errors were encountered: