playsocketjs 1.1.10 → 1.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2256,13 +2256,15 @@ function requireServer () {
|
|
|
2256
2256
|
* @private
|
|
2257
2257
|
*/
|
|
2258
2258
|
#handleMessage(ws, message) {
|
|
2259
|
+
if (ws.isTerminating) return;
|
|
2259
2260
|
try {
|
|
2260
2261
|
const data = decode(message);
|
|
2261
2262
|
|
|
2262
2263
|
// Apply rate limiting to all connections (including unregistered)
|
|
2263
2264
|
if (!this.#checkRateLimit(ws.connectionId, data.type)) {
|
|
2264
2265
|
ws.rateLimitViolations = (ws.rateLimitViolations || 0) + 1;
|
|
2265
|
-
if (ws.rateLimitViolations > 5) {
|
|
2266
|
+
if (ws.rateLimitViolations > 5 && !ws.isTerminating) {
|
|
2267
|
+
ws.isTerminating = true; // Prevent multiple terminate calls (it is async)
|
|
2266
2268
|
ws.terminate();
|
|
2267
2269
|
return console.error(`Connection ${ws.connectionId} terminated due to repeated rate limit violations.`);
|
|
2268
2270
|
}
|