@dev-anywhere/proxy 0.5.8 → 0.5.10

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/dist/serve.js CHANGED
@@ -735,6 +735,7 @@ var RelayConnection = class extends EventEmitter {
735
735
  this.ws.on("message", (data, isBinary) => {
736
736
  const buf = data;
737
737
  if (isBinary) {
738
+ this.clearHeartbeatTimeout();
738
739
  this.emit("binary", buf);
739
740
  return;
740
741
  }
@@ -753,6 +754,7 @@ var RelayConnection = class extends EventEmitter {
753
754
  serviceLogger.warn({ error: String(err) }, "Non-JSON message from relay, dropped");
754
755
  return;
755
756
  }
757
+ this.clearHeartbeatTimeout();
756
758
  if (msg.type === "proxy_register_response") {
757
759
  serviceLogger.info({ status: msg.status }, "Received register response");
758
760
  if (!this.fsm.tryTransitionTo(RelayConnectionState.SYNCED)) return;
@@ -6037,17 +6039,13 @@ var RemoteFileUploadManager = class {
6037
6039
  cancel(msg) {
6038
6040
  const active = this.activeUploads.get(msg.uploadId);
6039
6041
  if (!active) return;
6040
- active.completed = true;
6041
- this.activeUploads.delete(msg.uploadId);
6042
- active.stream.destroy();
6042
+ this.discard(msg.uploadId, active);
6043
6043
  serviceLogger.info({ uploadId: msg.uploadId }, "Remote file upload canceled");
6044
6044
  }
6045
6045
  fail(uploadId, error) {
6046
6046
  const active = this.activeUploads.get(uploadId);
6047
6047
  if (!active) return;
6048
- active.completed = true;
6049
- this.activeUploads.delete(uploadId);
6050
- active.stream.destroy();
6048
+ this.discard(uploadId, active);
6051
6049
  this.sendResponse({
6052
6050
  uploadId,
6053
6051
  sessionId: active.sessionId,
@@ -6056,6 +6054,26 @@ var RemoteFileUploadManager = class {
6056
6054
  errorCode: ControlErrorCode.UNKNOWN
6057
6055
  });
6058
6056
  }
6057
+ discard(uploadId, active) {
6058
+ active.completed = true;
6059
+ this.activeUploads.delete(uploadId);
6060
+ const removePartialFile = () => {
6061
+ try {
6062
+ unlinkIfPresent(active.path);
6063
+ } catch (err) {
6064
+ serviceLogger.warn(
6065
+ { uploadId, path: active.path, error: String(err) },
6066
+ "Failed to remove partial upload"
6067
+ );
6068
+ }
6069
+ };
6070
+ if (active.stream.closed) {
6071
+ removePartialFile();
6072
+ return;
6073
+ }
6074
+ active.stream.once("close", removePartialFile);
6075
+ active.stream.destroy();
6076
+ }
6059
6077
  sendResponse(payload) {
6060
6078
  this.deps.relayConnection.sendRaw(
6061
6079
  serializeControl({