8000 Reconnection attempts after close · Issue #2 · rexxars/eventsource-client · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Reconnection attempts after close #2

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

Clos 8000 ed
wiseman opened this issue May 3, 2024 · 1 comment
Closed

Reconnection attempts after close #2

wiseman opened this issue May 3, 2024 · 1 comment

Comments

@wiseman
Copy link
wiseman commented May 3, 2024

First, thank you so much for this code!

I don't think I'm doing anything fancy, but I'm seeing what look like reconnection attempts even after I've called EventSourceClient.close.

const sseSource = createEventSource({
	url: apiUrl,
	method: 'POST',
	headers: { 'Content-Type': 'application/json' },
	body: JSON.stringify(...)
});
console.log(1);
for await (const event of sseSource) {
	console.log(2, sseSource.readyState);
	// ...
	} else if (eventPayload.type === 'end') {
		break;
	}
}
sseSource.close();
console.log(3, sseSource.readyState);

I see the code break out of the loop and I see that the readyState is 'closed', but I still keep seeing repeated requests to the apiUrl.

Request call stack
  window.fetch            @ fetcher.js?v=9a498923:65
  connect                 @ eventsource-client.js?v=9a498923:153
  setTimeout (async)
  scheduleReconnect       @ eventsource-client.js?v=9a498923:200
  onFetchResponse         @ eventsource-client.js?v=9a498923:217
  Promise.then (async)
  connect                 @ eventsource-client.js?v=9a498923:153
  setTimeout (async)
  scheduleReconnect       @ eventsource-client.js?v=9a498923:200
  onFetchResponse         @ eventsource-client.js?v=9a498923:217
  Promise. then (async)   
  connect                 @ eventsource-client.js?v=9a498923:153
  setTimeout (async)
  scheduleReconnect       @ eventsource-client.js?v=9a498923:200
  (anonymous)             @ eventsource-client.js?v=9a498923:156

Thank you!

@rexxars rexxars closed this as completed in 3b13da7 May 6, 2024
@rexxars
Copy link
Owner
rexxars commented May 6, 2024

First, thank you so much for this code!

Thank you for the praise, always welcome :)

I don't think I'm doing anything fancy, but I'm seeing what look like reconnection attempts even after I've called EventSourceClient.close.

You're totally right.
I've fixed this issue and added tests to prevent this from regressing. Released as v1.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0