linkque-cli-v2 1.6.19 → 1.6.21

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.
package/dev/worker.js CHANGED
@@ -2357,12 +2357,17 @@ var require_websocket = __commonJS({
2357
2357
  protocols = [protocols];
2358
2358
  }
2359
2359
  }
2360
- initAsClient(this, address, protocols, options);
2360
+ options = initAsClient(this, address, protocols, options);
2361
2361
  } else {
2362
- this._autoPong = options.autoPong;
2363
- this._closeTimeout = options.closeTimeout;
2364
2362
  this._isServer = true;
2365
2363
  }
2364
+ if (options.autoPong) {
2365
+ this._autoPong = true;
2366
+ this._autoPongComplete = () => autoPongComplete(this);
2367
+ this._pendingAutoPongs = 0;
2368
+ this._maxPendingAutoPongs = options.maxPendingAutoPongs | 0;
2369
+ }
2370
+ this._closeTimeout = options.closeTimeout;
2366
2371
  }
2367
2372
  /**
2368
2373
  * For historical reasons, the custom "nodebuffer" type is used by the default
@@ -2773,6 +2778,7 @@ var require_websocket = __commonJS({
2773
2778
  maxBufferedChunks: 256 * 1024,
2774
2779
  maxFragments: 16 * 1024,
2775
2780
  maxPayload: 100 * 1024 * 1024,
2781
+ maxPendingAutoPongs: 60,
2776
2782
  skipUTF8Validation: false,
2777
2783
  perMessageDeflate: true,
2778
2784
  followRedirects: false,
@@ -2788,8 +2794,6 @@ var require_websocket = __commonJS({
2788
2794
  path: void 0,
2789
2795
  port: void 0
2790
2796
  };
2791
- websocket._autoPong = opts.autoPong;
2792
- websocket._closeTimeout = opts.closeTimeout;
2793
2797
  if (!protocolVersions.includes(opts.protocolVersion)) {
2794
2798
  throw new RangeError(
2795
2799
  `Unsupported protocol version: ${opts.protocolVersion} (supported versions: ${protocolVersions.join(", ")})`
@@ -3032,6 +3036,7 @@ var require_websocket = __commonJS({
3032
3036
  } else {
3033
3037
  req.end();
3034
3038
  }
3039
+ return opts;
3035
3040
  }
3036
3041
  function emitErrorAndClose(websocket, err) {
3037
3042
  websocket._readyState = WebSocket2.CLOSING;
@@ -3120,9 +3125,19 @@ var require_websocket = __commonJS({
3120
3125
  }
3121
3126
  function receiverOnPing(data) {
3122
3127
  const websocket = this[kWebSocket];
3123
- if (websocket._autoPong) websocket.pong(data, !this._isServer, NOOP);
3128
+ if (websocket._autoPong && websocket.readyState === WebSocket2.OPEN) {
3129
+ if (websocket._maxPendingAutoPongs > 0 && websocket._pendingAutoPongs >= websocket._maxPendingAutoPongs) {
3130
+ websocket.terminate();
3131
+ } else {
3132
+ websocket._pendingAutoPongs++;
3133
+ websocket.pong(data, !this._isServer, websocket._autoPongComplete);
3134
+ }
3135
+ }
3124
3136
  websocket.emit("ping", data);
3125
3137
  }
3138
+ function autoPongComplete(websocket) {
3139
+ websocket._pendingAutoPongs--;
3140
+ }
3126
3141
  function receiverOnPong(data) {
3127
3142
  this[kWebSocket].emit("pong", data);
3128
3143
  }
@@ -3376,6 +3391,8 @@ var require_websocket_server = __commonJS({
3376
3391
  * fragments
3377
3392
  * @param {Number} [options.maxPayload=104857600] The maximum allowed message
3378
3393
  * size
3394
+ * @param {Number} [options.maxPendingAutoPongs=60] The maximum number of
3395
+ * pending automatic pongs
3379
3396
  * @param {Boolean} [options.noServer=false] Enable no server mode
3380
3397
  * @param {String} [options.path] Accept only connections matching this path
3381
3398
  * @param {(Boolean|Object)} [options.perMessageDeflate=false] Enable/disable
@@ -3398,6 +3415,7 @@ var require_websocket_server = __commonJS({
3398
3415
  maxBufferedChunks: 256 * 1024,
3399
3416
  maxFragments: 16 * 1024,
3400
3417
  maxPayload: 100 * 1024 * 1024,
3418
+ maxPendingAutoPongs: 60,
3401
3419
  skipUTF8Validation: false,
3402
3420
  perMessageDeflate: false,
3403
3421
  handleProtocols: null,