Compare commits

..

1 Commits

Author SHA1 Message Date
Andrei f4422b6ba1
Merge 13d07079df into abb260632f 2025-04-25 17:45:48 +00:00
3 changed files with 5 additions and 13 deletions

View File

@ -1,5 +0,0 @@
---
'@hono/node-ws': patch
---
Fix missing code and reason on `CloseEvent`

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?.(