@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.
@@ -338,6 +338,7 @@ var PHPSandbox = (() => {
338
338
  PHPSandboxError: () => PHPSandboxError,
339
339
  PromiseTimeoutError: () => PromiseTimeoutError,
340
340
  RateLimitError: () => RateLimitError,
341
+ SendTimeoutError: () => SendTimeoutError,
341
342
  Transport: () => Transport,
342
343
  createBeacon: () => createBeacon,
343
344
  isBeaconSupported: () => isBeaconSupported,
@@ -2912,13 +2913,20 @@ var PHPSandbox = (() => {
2912
2913
  );
2913
2914
  var reconnecting_websocket_mjs_default = ReconnectingWebSocket;
2914
2915
 
2915
- // src/utils/promise.ts
2916
+ // src/errors/index.ts
2916
2917
  var PromiseTimeoutError = class extends Error {
2917
2918
  constructor(message, time) {
2918
2919
  super(message);
2919
2920
  this.time = time;
2920
2921
  }
2921
2922
  };
2923
+ var SendTimeoutError = class _SendTimeoutError extends PromiseTimeoutError {
2924
+ static fromPromiseTimeoutError(error) {
2925
+ return new _SendTimeoutError(error.message, error.time);
2926
+ }
2927
+ };
2928
+
2929
+ // src/utils/promise.ts
2922
2930
  var timeout = (prom, time) => {
2923
2931
  let timer;
2924
2932
  return Promise.race([
@@ -3269,7 +3277,12 @@ var PHPSandbox = (() => {
3269
3277
  if (!options.timeout) {
3270
3278
  return promise;
3271
3279
  }
3272
- return timeout(promise, options.timeout).finally(removeListeners);
3280
+ return timeout(promise, options.timeout).catch((error) => {
3281
+ if (error instanceof PromiseTimeoutError) {
3282
+ throw SendTimeoutError.fromPromiseTimeoutError(error);
3283
+ }
3284
+ throw error;
3285
+ }).finally(removeListeners);
3273
3286
  };
3274
3287
  return this.sendWithRetry(async () => await send(), options.retries || 10);
3275
3288
  }
@@ -3290,6 +3303,13 @@ var PHPSandbox = (() => {
3290
3303
  bail(e);
3291
3304
  return;
3292
3305
  }
3306
+ if (e instanceof SendTimeoutError) {
3307
+ this.reconnect();
3308
+ this.log("warn", "Send operation timed out, connection reset", {
3309
+ attempt,
3310
+ timeout: e.time
3311
+ });
3312
+ }
3293
3313
  this.log("debug", "Retrying send operation", {
3294
3314
  attempt,
3295
3315
  error: e instanceof Error ? e.message : String(e),