In upgradeWebSocket, a 'connection' event listener is being set on wss. As the number of new connections increases, the event is called the same number of times.
In upgradeWebSocket, only event listeners ('message', 'close', 'error') should be set on ws.
Initially, a new wss was created within upgradeWebSocket, so this issue did not occur. However, since wss is now reused, generated in injectWebSocket, this problem has arisen. (https://github.com/honojs/middleware/pull/539)
I attempted to fix the issue, but due to my shallow understanding of the middleware lifecycle, I couldn't succeed. Do you have any ideas?
In upgradeWebSocket, a 'connection' event listener is being set on
wss
. As the number of new connections increases, the event is called the same number of times.https://github.com/honojs/middleware/blob/ec6ec4ec02f8db46e3151e7334535e562dfc47e3/packages/node-ws/src/index.ts#L45-L98
In
upgradeWebSocket
, only event listeners ('message', 'close', 'error') should be set onws
.Initially, a new
wss
was created withinupgradeWebSocket
, so this issue did not occur. However, sincewss
is now reused, generated ininjectWebSocket
, this problem has arisen. (https://github.com/honojs/middleware/pull/539)I attempted to fix the issue, but due to my shallow understanding of the middleware lifecycle, I couldn't succeed. Do you have any ideas?
@nakasyou @mikestopcontinues