@fastify/websocket
Advanced tools
Comparing version 7.1.0 to 7.1.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": "7.1.0", | ||
"version": "7.1.1", | ||
"description": "basic websocket support for fastify", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -132,5 +132,6 @@ # @fastify/websocket | ||
import Fastify from 'fastify' | ||
import websocket from '@fastify/websocket' | ||
const fastify = Fastify() | ||
await fastify.register(require('@fastify/websocket')) | ||
await fastify.register(websocket) | ||
@@ -137,0 +138,0 @@ fastify.get('/', { websocket: true }, function wsHandler (connection, req) { |
@@ -567,1 +567,23 @@ 'use strict' | ||
}) | ||
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
81608
1846
275