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

WebSockets appear to be broken in 0.5.1 #443

Open
thedocbwarren opened this issue Dec 23, 2024 · 2 comments
Open

WebSockets appear to be broken in 0.5.1 #443

thedocbwarren opened this issue Dec 23, 2024 · 2 comments

Comments

@thedocbwarren
Copy link

Web sockets (even using the example) do not work. They startup and report enabling, but do not connect at all. I've also tried using h3 bindings and could not get anything to connect.

Easy way to test, run SSR/Basic example and attempt to connect.

@dotnize
Copy link

dotnize commented Dec 25, 2024

What I did for now is patch node_modules/vinxi/lib/nitro-dev.js with the fix in that PR. (e.g. pnpm patch vinxi)

diff --git a/lib/nitro-dev.js b/lib/nitro-dev.js
index 83b082422216bb63abf201550cc4b380db794e1b..1fe4826e21bbfd9b2d062fe3fcbf4460c2991ce5 100644
--- a/lib/nitro-dev.js
+++ b/lib/nitro-dev.js
@@ -293,26 +293,7 @@ export async function createDevServer(nitro) {
 	// 	}),
 	// );
 
-	const adapter = wsAdapter({
-		...wsApp.websocket,
-		hooks: {
-			open: (event) => {
-				event.ctx.node.req.url = event.ctx.node.req.originalUrl;
-			},
-			message: (event) => {
-				event.ctx.node.req.url = event.ctx.node.req.originalUrl;
-			},
-			close: (event) => {
-				event.ctx.node.req.url = event.ctx.node.req.originalUrl;
-			},
-			error: (event) => {
-				event.ctx.node.req.url = event.ctx.node.req.originalUrl;
-			},
-			upgrade: (event) => {
-				// event.ctx.node.req.url = event.ctx.node.req.originalUrl;
-			},
-		},
-	});
+	const adapter = wsAdapter(wsApp.websocket);
 	// Listen
 	/** @type {import("@vinxi/listhen").Listener[]}  */
 	let listeners = [];

@thedocbwarren
Copy link
Author

Not wanting to patch like this as this is for production. Also it looks like it's the nitro dev server? Is that correct or am I misreading?

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