@waffle-os/runtime 0.0.151 → 0.0.152

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.
@@ -340,6 +340,12 @@ export type PeerMessage =
340
340
  readonly totalBytes: number;
341
341
  readonly chunk: Uint8Array;
342
342
  }
343
+ | {
344
+ readonly kind: "chunk-abort";
345
+ readonly hostTerm: string;
346
+ readonly sessionId: string;
347
+ readonly uploadId: string;
348
+ }
343
349
  | {
344
350
  readonly kind: "chunk-get";
345
351
  readonly hostTerm: string;
@@ -378,6 +384,7 @@ export type PeerMessage =
378
384
  readonly pendingWatchAcks?: readonly (readonly [number, boolean])[];
379
385
  readonly pendingUnpins?: readonly number[];
380
386
  readonly pendingWatchCloses?: readonly number[];
387
+ readonly pendingUploadAborts?: readonly string[];
381
388
  }
382
389
  | {
383
390
  readonly kind: "pong";
@@ -389,6 +396,7 @@ export type PeerMessage =
389
396
  readonly settledWatchAcks?: readonly number[];
390
397
  readonly settledUnpins?: readonly number[];
391
398
  readonly settledWatchCloses?: readonly number[];
399
+ readonly settledUploadAborts?: readonly string[];
392
400
  readonly creditLimit: PeerCreditLimit;
393
401
  readonly hostState: HostHealthState;
394
402
  }
@@ -430,6 +438,7 @@ export type PeerMessage =
430
438
  readonly watchAcks?: readonly number[];
431
439
  readonly unpins?: readonly number[];
432
440
  readonly watchCloses?: readonly number[];
441
+ readonly uploadAborts?: readonly string[];
433
442
  }
434
443
  | {
435
444
  readonly kind: "detach";
@@ -534,6 +543,8 @@ export function isPeerMessage(value: unknown): value is PeerMessage {
534
543
  typeof value.totalBytes === "number" &&
535
544
  value.chunk instanceof Uint8Array
536
545
  );
546
+ case "chunk-abort":
547
+ return typeof value.uploadId === "string";
537
548
  case "chunk-get":
538
549
  return (
539
550
  typeof value.reqId === "number" &&
package/fs/service.ts CHANGED
@@ -1169,18 +1169,40 @@ export class FilesystemService {
1169
1169
  return;
1170
1170
  }
1171
1171
  if (operation === "flush" || operation === "sync") {
1172
- const flushing = this.backend.flush?.(
1173
- operation === "sync" ? a : typeof a === "string" ? a : undefined,
1174
- );
1175
- return this.trackRequestWork(session, Promise.resolve(flushing)).then(() =>
1176
- this.finishResult(session, id, operation, operation === "sync" ? 0 : undefined),
1172
+ const target = operation === "sync" ? a : typeof a === "string" ? a : undefined;
1173
+ if (operation === "sync") this.backend.retain(a);
1174
+ let flushing: Promise<void> | undefined;
1175
+ try {
1176
+ flushing = this.backend.flush?.(target);
1177
+ } catch (error) {
1178
+ if (operation === "sync") this.backend.release(a);
1179
+ throw error;
1180
+ }
1181
+ return this.trackRequestWork(session, Promise.resolve(flushing)).then(
1182
+ () => {
1183
+ if (operation === "sync") this.backend.release(a);
1184
+ return this.finishResult(session, id, operation, operation === "sync" ? 0 : undefined);
1185
+ },
1186
+ (error) => {
1187
+ if (operation === "sync") this.backend.release(a);
1188
+ throw error;
1189
+ },
1177
1190
  );
1178
1191
  }
1179
1192
  if (operation === "resolve" && session.socketScope && this.backend instanceof MemoryBackend) {
1180
1193
  const result = this.backend.fs.resolveSocket(a, b, c === true);
1181
1194
  return this.finishResult(session, id, operation, result, args);
1182
1195
  }
1183
- const result = this.backend.execute(operation, args, data);
1196
+ const isCancelled = () => {
1197
+ const pending = session.pending.get(id);
1198
+ return (
1199
+ !pending ||
1200
+ sessionRevoked(session) ||
1201
+ !this.sessions.has(session) ||
1202
+ requestCancelled(pending)
1203
+ );
1204
+ };
1205
+ const result = this.backend.execute(operation, args, data, isCancelled);
1184
1206
  if (result instanceof Promise)
1185
1207
  return this.trackRequestWork(session, result).then((value) =>
1186
1208
  this.finishResult(session, id, operation, value, args),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waffle-os/runtime",
3
- "version": "0.0.151",
3
+ "version": "0.0.152",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/ShaulLavo/waffle.git",
@@ -1 +1 @@
1
- {"commit":"da522cacff05cf6f18e820967a2e0f52d2f19680","buildToolsSha256":"b617652c1601f8722bb85c3a688a1fca4985b53f2c2066c10c76c2e693081137","optimizerSourceSha256":"34c4a040f3cf639f039823880822c6541c384c9b4eaa116d27dda8d9cb5c9f9e"}
1
+ {"commit":"72849910ef1260a1e27ec37e6b3a8e0371f71de3","buildToolsSha256":"b617652c1601f8722bb85c3a688a1fca4985b53f2c2066c10c76c2e693081137","optimizerSourceSha256":"34c4a040f3cf639f039823880822c6541c384c9b4eaa116d27dda8d9cb5c9f9e"}