Compare commits

..

1 Commits

Author SHA1 Message Date
Taras Glek 14e34a4672
Merge 215f376d4b into abb260632f 2025-04-18 07:55:14 +00:00
4 changed files with 6 additions and 15 deletions

View File

@ -1,11 +1,5 @@
# @hono/node-ws
## 1.1.2
### Patch Changes
- [#1138](https://github.com/honojs/middleware/pull/1138) [`237bff1b82f2c0adfcd015dc97538b36cfb5d418`](https://github.com/honojs/middleware/commit/237bff1b82f2c0adfcd015dc97538b36cfb5d418) Thanks [@leia-uwu](https://github.com/leia-uwu)! - Fix missing code and reason on `CloseEvent`
## 1.1.1
### Patch Changes

View File

@ -1,6 +1,6 @@
{
"name": "@hono/node-ws",
"version": "1.1.2",
"version": "1.1.1",
"description": "WebSocket helper for Node.js",
"type": "module",
"main": "dist/index.js",

View File

@ -170,21 +170,18 @@ describe('WebSocket helper', () => {
})
it('CloseEvent should be executed without crash', async () => {
const testCode = 3001
const testReason = 'Test!'
app.get(
'/',
upgradeWebSocket(() => ({
onClose(event) {
expect(event.code).toBe(testCode)
expect(event.reason).toBe(testReason)
onClose() {
// doing some stuff here
},
}))
)
const ws = new WebSocket('ws://localhost:3030/')
await new Promise<void>((resolve) => ws.on('open', resolve))
ws.close(testCode, testReason)
ws.close()
})
it('Should be able to send and receive binary content with good length', async () => {

View File

@ -126,8 +126,8 @@ export const createNodeWebSocket = (init: NodeWebSocketInit): NodeWebSocket => {
)
}
})
ws.on('close', (code, reason) => {
events.onClose?.(new CloseEvent('close', { code, reason: reason.toString() }), ctx)
ws.on('close', () => {
events.onClose?.(new CloseEvent('close'), ctx)
})
ws.on('error', (error) => {
events.onError?.(