nuxt-directus
nuxt-directus copied to clipboard
useDirectusRealtime cannot establish connection to the Websocket
Version
nuxt-directus-next v0.0.15 nuxt: v3.12.2
Reproduction Link
https://github.com/Lucas-Gruber/nuxt-directus-reproduction-websocket
Steps to reproduce
- Install the packages (
yarn install) - Set the Directus link in nuxt.config.ts
- Start the dev-server with
yarn dev - Look in the browser-console
What is Expected?
The socket should connect and print this in console.
What is actually happening?
An error appears and the connection cannot be established.
Error:
t.globals.WebSocket is not a constructor
at new Promise ()
at connect (https://raw.githubusercontent.com/directus/directus/v10.10.5/sdk/src/realtime/composable.ts:231:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async setup (./app.js:15:84)
Sorry @Lucas-Gruber for not reaching out earlier, had a busy week.
Yes, indeed it is an SSR related issue (the composable tries to establish a connection while still server-side). I got the fix mostly drafted but I need to investigate if I'm able to hook the id generation from the sdk ws composable (to prevent from sending queued messages and new messages with same ids)
No problem! And thank you for your work on this issue!
Are there any news on this?
Are there any news on this?
Yes, but unfortunately they do require a custom implementation that could easily break with future SDK updates. On this subject I do plan to write a comment in #215 in the upcoming days/week to get some feedback on future plans I have.
Sorry for the delay, but I've also taken a few weeks off from basically everything (actually I'm still on holidays)
--> https://github.com/Intevel/nuxt-directus/discussions/271
nuxt-directus-next is EOL