socketio / socket.io-website

Socket.IO website and blog
https://socket.io
318 stars 668 forks source link

WebTransport example: WebTransport server throws error #430

Closed matthiasgeihs closed 7 months ago

matthiasgeihs commented 8 months ago

Location Website Socket.IO with WebTransport

Describe the bug When running the WebTransport server code as posted in the article, at line const stream = await h3Server.sessionStream("/socket.io/");, I get the following error:

[...]/node_modules/@fails-components/webtransport/lib/server.js:105
      this.transportInt.addPath(path)
                        ^

TypeError: Cannot read properties of undefined (reading 'addPath')

To Reproduce

Run the server code (including the WebTransport server) included at the bottom of the article linked above.

Expected behavior Should work as described in article.

Platform:

Additional context The problem stems from the fact that h3Server.sessionStream(...) is called before h3Server.startServer(). sessionStream tries to access transportInt, but transportInt is only initialized at startServer(). To resolve this, h3Server.startServer(); should be placed before the async block in the example.

darrachequesne commented 7 months ago

I've updated the example: https://github.com/socketio/socket.io-website/commit/4a87e970a9d31840a45d64fd28f69757096bc5cc

Thanks for the heads-up :+1: