1- import { WebSocket as WsWebSocket , WebSocketServer } from 'ws'
1+ import { WebSocket as WsWebSocket } from 'ws'
22import { WebSocket as UndiciWebSocket } from '../../index.js'
33import { randomBytes } from 'node:crypto'
44import { bench , run , group } from 'mitata'
@@ -12,24 +12,9 @@ if (__GLOBAL_WEBSOCKET__ && typeof globalThis.WebSocket === 'function') {
1212 GlobalWebSocket = globalThis . WebSocket
1313}
1414
15- const server = new WebSocketServer ( { port : 5001 } )
1615const binary = randomBytes ( __BINARY_SIZE__ ) . toString ( 'utf-8' )
1716
18- // Workaround for https://github.com/nodejs/undici/issues/3202
19- const emptyBuffer = Buffer . allocUnsafe ( 1 )
20-
21- server . on ( 'connection' , ( socket ) => {
22- socket . on ( 'message' , ( _data , _isBinary ) => {
23- socket . send ( emptyBuffer )
24- // socket.close();
25- } )
26- } )
27-
28- await new Promise ( ( resolve , _reject ) => {
29- server . on ( 'listening' , resolve )
30- } )
31-
32- const url = `http://localhost:${ server . address ( ) . port } `
17+ const url = 'http://localhost:5001'
3318
3419const connections = [ ]
3520
@@ -93,8 +78,6 @@ for (const ws of connections) {
9378
9479await run ( )
9580
96- server . close ( )
97-
9881for ( const ws of connections ) {
9982 ws . close ( )
10083}
0 commit comments