Skip to content

Commit 9f1116e

Browse files
committed
🔧 fix: merge pr
1 parent d3c6d90 commit 9f1116e

6 files changed

Lines changed: 55 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 1.4.2 - 4 Nov 2025
2+
Bug fix:
3+
- [#52](https://github.com/elysiajs/node/pull/52) incorrectly constructed responses for 204 status codes
4+
- [#50](https://github.com/elysiajs/node/issues/50) websockets ws.data is `undefined`
5+
16
# 1.4.1 - 16 Sep 2025
27
Change:
38
- use srvx for full Web Standard Compatibility

bun.lock

Lines changed: 33 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,17 @@ const app = new Elysia({
1515
},
1616
message(ws, message) {
1717
ws.send(message)
18-
},
19-
close(ws, code, reason) {}
18+
}
2019
})
2120
.get('/image', async () => file('test/kyuukurarin.mp4'))
2221
.get('/generator', async function* () {
23-
for (let i = 0; i < 100; i++) {
22+
for (let i = 0; i < 10000; i++) {
2423
await new Promise((resolve) => setTimeout(resolve, 10))
25-
yield sse('A')
24+
yield 'A'
2625
}
2726
})
2827
.post('/', ({ body }) => body, {
29-
type: 'json'
28+
parse: 'json'
3029
})
3130
.get('/', ({ request }) => {
3231
console.log(request)

example/video.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Elysia, file, sse } from 'elysia'
2+
3+
import { node } from '../src'
4+
5+
new Elysia({ adapter: node() })
6+
.get('/video', file('test/kyuukurarin.mp4'))
7+
.listen(3000)

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@
1212
},
1313
"dependencies": {
1414
"crossws": "^0.4.1",
15-
"srvx": "^0.8.9"
15+
"srvx": "^0.9.4"
1616
},
1717
"peerDependencies": {
1818
"elysia": ">= 1.4.0"
1919
},
2020
"devDependencies": {
2121
"@elysiajs/cors": "^1.4.0",
2222
"@elysiajs/openapi": "^1.4.0",
23+
"@types/bun": "^1.3.1",
2324
"@types/node": "^22.10.2",
24-
"elysia": "^1.4.9",
25+
"elysia": "^1.4.15",
2526
"eslint": "9.17.0",
2627
"tsup": "^8.3.5",
2728
"tsx": "^4.19.2",

src/ws.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ export function createWebSocketAdapter() {
5555
normalize: app.config.normalize
5656
})
5757

58-
const toServerWebSocket = (peer: Peer) => {
58+
const toServerWebSocket = (peer: Peer, context: Context) => {
5959
const ws = peer as any as ServerWebSocket<any>
6060

6161
// @ts-ignore, context.context is intentional
6262
// first context is srvx.context (alias of bun.ws.data)
6363
// second context is Elysia context
64-
ws.data = peer.context.context
64+
ws.data = context
6565
ws.sendText = ws.send
6666
ws.sendBinary = ws.send
6767
ws.publishText = ws.publish
@@ -164,7 +164,7 @@ export function createWebSocketAdapter() {
164164
return options.pong?.(data) as number
165165
},
166166
async open(_ws) {
167-
const ws = toServerWebSocket(_ws)
167+
const ws = toServerWebSocket(_ws, context)
168168

169169
try {
170170
await handleResponse(

0 commit comments

Comments
 (0)