@phpsandbox/sdk 0.0.5 → 0.0.6

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.
@@ -2874,13 +2874,20 @@ var ReconnectingWebSocket = (
2874
2874
  );
2875
2875
  var reconnecting_websocket_mjs_default = ReconnectingWebSocket;
2876
2876
 
2877
- // src/utils/promise.ts
2877
+ // src/errors/index.ts
2878
2878
  var PromiseTimeoutError = class extends Error {
2879
2879
  constructor(message, time) {
2880
2880
  super(message);
2881
2881
  this.time = time;
2882
2882
  }
2883
2883
  };
2884
+ var SendTimeoutError = class _SendTimeoutError extends PromiseTimeoutError {
2885
+ static fromPromiseTimeoutError(error) {
2886
+ return new _SendTimeoutError(error.message, error.time);
2887
+ }
2888
+ };
2889
+
2890
+ // src/utils/promise.ts
2884
2891
  var timeout = (prom, time) => {
2885
2892
  let timer;
2886
2893
  return Promise.race([
@@ -3231,7 +3238,12 @@ var Transport = class {
3231
3238
  if (!options.timeout) {
3232
3239
  return promise;
3233
3240
  }
3234
- return timeout(promise, options.timeout).finally(removeListeners);
3241
+ return timeout(promise, options.timeout).catch((error) => {
3242
+ if (error instanceof PromiseTimeoutError) {
3243
+ throw SendTimeoutError.fromPromiseTimeoutError(error);
3244
+ }
3245
+ throw error;
3246
+ }).finally(removeListeners);
3235
3247
  };
3236
3248
  return this.sendWithRetry(async () => await send(), options.retries || 10);
3237
3249
  }
@@ -3252,6 +3264,13 @@ var Transport = class {
3252
3264
  bail(e);
3253
3265
  return;
3254
3266
  }
3267
+ if (e instanceof SendTimeoutError) {
3268
+ this.reconnect();
3269
+ this.log("warn", "Send operation timed out, connection reset", {
3270
+ attempt,
3271
+ timeout: e.time
3272
+ });
3273
+ }
3255
3274
  this.log("debug", "Retrying send operation", {
3256
3275
  attempt,
3257
3276
  error: e instanceof Error ? e.message : String(e),
@@ -4739,6 +4758,7 @@ export {
4739
4758
  PHPSandboxError,
4740
4759
  PromiseTimeoutError,
4741
4760
  RateLimitError,
4761
+ SendTimeoutError,
4742
4762
  Transport,
4743
4763
  createBeacon,
4744
4764
  isBeaconSupported,