@fastify/websocket
Advanced tools
Comparing version 5.0.0 to 5.0.1
@@ -64,2 +64,6 @@ 'use strict' | ||
connection.on('error', (error) => { | ||
fastify.log.error(error) | ||
}) | ||
connection.socket.on('newListener', event => { | ||
@@ -66,0 +70,0 @@ if (event === 'message') { |
{ | ||
"name": "@fastify/websocket", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "basic websocket support for fastify", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -10,2 +10,3 @@ 'use strict' | ||
const WebSocket = require('ws') | ||
const { once } = require('events') | ||
@@ -598,1 +599,23 @@ test('Should expose a websocket', (t) => { | ||
}) | ||
test('Should Handle WebSocket errors to avoid Node.js crashes', async t => { | ||
t.plan(1) | ||
const fastify = Fastify() | ||
await fastify.register(fastifyWebsocket) | ||
fastify.get('/', { websocket: true }, ({ socket }) => { | ||
socket.on('error', err => { | ||
t.equal(err.code, 'WS_ERR_UNEXPECTED_RSV_2_3') | ||
}) | ||
}) | ||
await fastify.listen({ port: 0 }) | ||
const client = new WebSocket('ws://localhost:' + fastify.server.address().port) | ||
await once(client, 'open') | ||
client._socket.write(Buffer.from([0xa2, 0x00])) | ||
await fastify.close() | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73602
1678