Skip to content
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

error: Uncaught (in promise) Http: connection closed before message completed #100

Closed
LoganTann opened this issue Jul 11, 2022 · 6 comments · Fixed by #101
Closed

error: Uncaught (in promise) Http: connection closed before message completed #100

LoganTann opened this issue Jul 11, 2022 · 6 comments · Fixed by #101

Comments

@LoganTann
Copy link

LoganTann commented Jul 11, 2022

Sometimes, the following error appears randomly when I do a request :

error: Uncaught (in promise) Http: connection closed before message completed
    at Object.respondWith (deno:ext/http/01_http.js:254:21)

Unfortunately, I don't have further information. I can't even reproduce sometimes.

The following github issue and linked threads might help : denoland/deno#13203

@LoganTann
Copy link
Author

It also happens a lot when returning a server sent event.

@LoganTann
Copy link
Author

This issue is very blocking as it causes the server to completely crash @gr7d

I believe we should handle the error at this line : https://github.com/gr7d/aqua/blob/main/shared.ts#L57C20-L57C20

@predetermined
Copy link
Owner

I'm currently trying to reproduce it. If you have any tips, I'd be thankful.

@LoganTann
Copy link
Author

I can confirm adding a .catch() on the line I mentioned fixed the issue.

@gr7d If you have any tips, I'd be thankful.

To create a reproduction code (with aqua v1), you may try this :

app.get("/progress", (req) => {
	let interval: number;
	const stream = new ReadableStream({
	  start(controller) {
		interval = setInterval(() => {
			const val = `data: ${new Date().toISOString()}\r\n\r\n`;
			controller.enqueue(new TextEncoder().encode(val));
		}, 300);
	  },
	  cancel() {
		clearInterval(interval);
	  }
	});
  
	return {
	  content: stream,
	  headers: {
		"Content-Type": "text/event-stream"
	  }
	};
  });

Then, create an HTML page to subscribe to the event source using the new EventSource("/progress") API.

Reload multiple times the page and you might get the error I described.

@predetermined
Copy link
Owner

Fix (#101) included in release v1.3.6. Thanks for your patience :)

@LoganTann
Copy link
Author

Thank you too for maintaining this lib, it is very simple, and I'm using it in many projects !

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

Successfully merging a pull request may close this issue.

2 participants