@phpsandbox/sdk 0.0.19 → 0.0.20

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.
@@ -2962,6 +2962,7 @@ var Transport = class {
2962
2962
  this.closed = false;
2963
2963
  this.disposables = new NamedDisposable();
2964
2964
  this.connectPromise = null;
2965
+ this.pingIntervalStarted = false;
2965
2966
  // Connection health monitoring
2966
2967
  this.connectionStats = {
2967
2968
  connectTime: 0,
@@ -3040,7 +3041,25 @@ var Transport = class {
3040
3041
  throw new Error("Unexpected message type: " + typeof ev.data);
3041
3042
  }
3042
3043
  ev.data.arrayBuffer().then((buffer) => {
3043
- this.handleRawMessage(decode(buffer));
3044
+ if (buffer.byteLength === 0) {
3045
+ this.log("warn", "Ignoring empty WebSocket frame");
3046
+ return;
3047
+ }
3048
+ try {
3049
+ this.handleRawMessage(decode(buffer));
3050
+ } catch (error) {
3051
+ this.connectionStats.totalErrors++;
3052
+ this.log("error", "Failed to decode WebSocket frame", {
3053
+ error: error instanceof Error ? error.message : String(error),
3054
+ byteLength: buffer.byteLength
3055
+ });
3056
+ this.eventEmitter.emit("transport.error", {
3057
+ type: "message_decode_error",
3058
+ error,
3059
+ rawMessage: buffer,
3060
+ timestamp: Date.now()
3061
+ });
3062
+ }
3044
3063
  });
3045
3064
  };
3046
3065
  this.rws.addEventListener("message", onMessage);
@@ -3685,6 +3704,10 @@ connect_fn = function() {
3685
3704
  return this.connectPromise;
3686
3705
  };
3687
3706
  startPeriodicPing_fn = function() {
3707
+ if (this.pingIntervalStarted || this.closed) {
3708
+ return;
3709
+ }
3710
+ this.pingIntervalStarted = true;
3688
3711
  this.disposables.add("pingInterval", () => {
3689
3712
  const interval = setInterval(async () => {
3690
3713
  try {
@@ -3708,6 +3731,7 @@ startPeriodicPing_fn = function() {
3708
3731
  return {
3709
3732
  dispose: () => {
3710
3733
  clearInterval(interval);
3734
+ this.pingIntervalStarted = false;
3711
3735
  }
3712
3736
  };
3713
3737
  });