WebSocket connection succeeds but Elysia WebSocket handler is not triggered when running inside Nitro
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- bun, typescript
Research direction
Start by running the provided Elysia app inside Nitro with the shown websocket configuration and client. Trace Nitro's websocket handling and the Elysia integration to find why the successful handshake does not invoke the registered /ws handler. Done means the handler runs after connection and the client receives 1, 2, and 3.
Written by the indexing model from the issue text.
Description
Environment
node
Reproduction
I am using Elysia as a handler inside Nitro. I enabled WebSocket support in Elysia and the WebSocket connection can be established successfully, but the Elysia WebSocket handler is never executed.
Environment
- Nitro version:
- Elysia version:
- Runtime: Bun
- OS:
Reproduction
Elysia app:
import { Elysia } from 'elysia'
import { websocket } from 'elysia/websocket'
export const app = new Elysia()
.use(websocket())
.ws('/ws', function* () {
console.log('handler entered')
yield 1
yield 2
yield 3
})
Nitro config:
export default defineNitroConfig({
features: {
websocket: true
}
})
Client:
const ws = new WebSocket('ws://localhost:3000/ws')
ws.onopen = () => {
console.log('connected')
}
ws.onmessage = (event) => {
console.log(event.data)
}
Expected behavior
After the WebSocket connection is established, the Elysia WebSocket handler should be executed:
connected
handler entered
1
2
3
Actual behavior
The WebSocket handshake succeeds:
WebSocket connection established
but the Elysia handler is never entered:
(no console output)
No error is thrown.
Describe the bug
none
Additional context
No response
Logs
- Dominant language
- TypeScript
- Stars
- 11.5k
- Forks
- 968
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 64
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nitrojs/nitro
-
pending triage
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Maintainers usually reply within 2 days
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
Maintainers usually reply within 2 days
-
cloudflare: `nitro deploy` fails when a parent directory has a Wrangler configPossibly taken @draarivpatel-ui claimed this 13 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 2 days
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 2 days
-
pending triage
Difficulty 5/5 Over a week Newbie friendliness 30/100
nitrojs/nitro#5205 · 1 reaction ·
Maintainers usually reply within 2 days
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ranxianglei/billion-context#8319 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
JimLiu/open-artifact#126 ·
-
bug repro-ready
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
mksglu/context-mode#1454 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
laststance/design-world#98 ·
Maintainers usually reply within 1 day
-
Add: KCM True crimeOpenapproved check:passed streams:add
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day