@ai-ecoverse/slicc-kernel 1.170.4 → 1.171.0

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/node.js CHANGED
@@ -2362,9 +2362,9 @@ var KernelSocket = class _KernelSocket {
2362
2362
  case SO_TYPE:
2363
2363
  return SOCK_STREAM;
2364
2364
  case SO_ERROR: {
2365
- const failed3 = this.failed;
2365
+ const failed4 = this.failed;
2366
2366
  this.failed = void 0;
2367
- return failed3 ? wasiErrno(failed3) : 0;
2367
+ return failed4 ? wasiErrno(failed4) : 0;
2368
2368
  }
2369
2369
  case SO_ACCEPTCONN:
2370
2370
  return this.state === "listening" ? 1 : 0;
@@ -3695,7 +3695,7 @@ function satisfies(version, range2) {
3695
3695
  }
3696
3696
 
3697
3697
  // src/version.ts
3698
- var KERNEL_VERSION = true ? "1.170.4" : "0.0.0-dev";
3698
+ var KERNEL_VERSION = true ? "1.171.0" : "0.0.0-dev";
3699
3699
  var OS_RELEASE = "6.0.0-slicc";
3700
3700
  function procVersion() {
3701
3701
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -3987,10 +3987,10 @@ async function tierPackages(fs, physical, roots, bins, kernel, global) {
3987
3987
  const own = commandsOf(pkg, manifest);
3988
3988
  const named = new Set(own.map((command) => command.name));
3989
3989
  const extra = bins ? await binCommandsOf(physical, pkg, manifest, named) : [];
3990
- const refused3 = engineRefusal(manifest, kernel);
3990
+ const refused4 = engineRefusal(manifest, kernel);
3991
3991
  const name2 = pkg.slice(root.length + 1);
3992
3992
  const dependency = direct?.has(name2) === false;
3993
- const marks = { ...refused3 ? { refused: refused3 } : {}, ...dependency ? { dependency } : {} };
3993
+ const marks = { ...refused4 ? { refused: refused4 } : {}, ...dependency ? { dependency } : {} };
3994
3994
  out.push({
3995
3995
  name: name2,
3996
3996
  pkg,
@@ -4022,7 +4022,7 @@ function winners(tier) {
4022
4022
  }
4023
4023
  return out;
4024
4024
  }
4025
- async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY, kernel = KERNEL_VERSION, refused3, global = /* @__PURE__ */ new Set()) {
4025
+ async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY, kernel = KERNEL_VERSION, refused4, global = /* @__PURE__ */ new Set()) {
4026
4026
  const found = /* @__PURE__ */ new Map();
4027
4027
  const physical = physicalResolver(fs);
4028
4028
  const tiers = (typeof modules === "string" ? [modules] : modules).map(
@@ -4036,7 +4036,7 @@ async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY, ke
4036
4036
  const dependencies = [];
4037
4037
  for (const [index, roots] of tiers.entries()) {
4038
4038
  const tier = await tierPackages(fs, physical, roots, index >= binsFrom, kernel, global);
4039
- if (refused3) refused3.push(...tier.flatMap((entry) => entry.commands.filter((c) => c.refused)));
4039
+ if (refused4) refused4.push(...tier.flatMap((entry) => entry.commands.filter((c) => c.refused)));
4040
4040
  await take(tier.filter((entry) => !entry.dependency));
4041
4041
  dependencies.push(tier.filter((entry) => entry.dependency));
4042
4042
  }
@@ -5102,12 +5102,12 @@ var UnlinkedKeeper = class {
5102
5102
  return this.locks;
5103
5103
  }
5104
5104
  async undoing(op, peers, sends, heard, shared2 = []) {
5105
- let failed3;
5105
+ let failed4;
5106
5106
  let out;
5107
5107
  try {
5108
5108
  out = await op();
5109
5109
  } catch (err) {
5110
- failed3 = err ?? new Error("failed");
5110
+ failed4 = err ?? new Error("failed");
5111
5111
  await this.rollBackAsides(sends, shared2);
5112
5112
  }
5113
5113
  const hiddenShared = new Set(shared2.map((one) => one.hidden));
@@ -5128,7 +5128,7 @@ var UnlinkedKeeper = class {
5128
5128
  const done4 = () => one.release().then(() => this.dropIfLast(one.hidden));
5129
5129
  void Promise.all(waits.map(({ told }) => told)).then(done4, done4);
5130
5130
  }
5131
- if (failed3 !== void 0) throw failed3;
5131
+ if (failed4 !== void 0) throw failed4;
5132
5132
  return out;
5133
5133
  }
5134
5134
  async rollBackAsides(sends, shared2) {
@@ -6190,8 +6190,8 @@ var RealmProxy = class {
6190
6190
  }
6191
6191
  async connect(conn, incoming, req, idle2) {
6192
6192
  const target = tunnelTarget(req);
6193
- const refused3 = target.port === 443 ? await this.tunnelReady(target) : void 0;
6194
- if (refused3) throw refused3;
6193
+ const refused4 = target.port === 443 ? await this.tunnelReady(target) : void 0;
6194
+ if (refused4) throw refused4;
6195
6195
  await conn.write(latin1Bytes("HTTP/1.1 200 Connection Established\r\n\r\n"), this.stop.signal);
6196
6196
  try {
6197
6197
  const first = await incoming.peek(this.stop.signal);
@@ -9366,8 +9366,8 @@ var DriverConnection = class _DriverConnection {
9366
9366
  } finally {
9367
9367
  clearTimeout(timer);
9368
9368
  }
9369
- const refused3 = driverVersionError(hello.protocol);
9370
- if (refused3) throw errnoError("EPROTO", refused3);
9369
+ const refused4 = driverVersionError(hello.protocol);
9370
+ if (refused4) throw errnoError("EPROTO", refused4);
9371
9371
  if (hello.error) throw errnoError(hello.errno ?? "EIO", hello.error);
9372
9372
  return new _DriverConnection(port, hello.capabilities ?? {}, waiting, timeoutMs, options);
9373
9373
  }
@@ -11391,8 +11391,8 @@ async function guarded(entry, path, req) {
11391
11391
  return { paths };
11392
11392
  } catch (err) {
11393
11393
  const refusal3 = err.code === "EACCES";
11394
- const refused3 = req.op === "exists" && refusal3 ? json2(false) : toErrno(err);
11395
- return { refused: refused3 };
11394
+ const refused4 = req.op === "exists" && refusal3 ? json2(false) : toErrno(err);
11395
+ return { refused: refused4 };
11396
11396
  }
11397
11397
  }
11398
11398
  async function copyOp(entry, path, req) {
@@ -11588,13 +11588,13 @@ async function created(entry, req) {
11588
11588
  return seen === void 0 ? looked : json2({ ...looked.json, seen });
11589
11589
  }
11590
11590
  var DENIED = /* @__PURE__ */ new Set(["EACCES", "EPERM"]);
11591
- async function rmPermitted(entry, path, req, refused3) {
11591
+ async function rmPermitted(entry, path, req, refused4) {
11592
11592
  const st = await entry.fs.lstat(path).catch(() => void 0);
11593
- if (!st?.isDirectory) return refused3;
11593
+ if (!st?.isDirectory) return refused4;
11594
11594
  const unlisted = await guarded(entry, path, { ...req, op: "readdir" });
11595
11595
  if ("refused" in unlisted) return unlisted.refused;
11596
11596
  const names2 = await entry.fs.readdir(path).catch(() => void 0);
11597
- if (!names2) return refused3;
11597
+ if (!names2) return refused4;
11598
11598
  let first;
11599
11599
  for (const name2 of names2) {
11600
11600
  const child = await dispatchOne(entry, {
@@ -11645,14 +11645,14 @@ async function newDevName(entry, path, req) {
11645
11645
  const named = NAMING.has(req.op);
11646
11646
  if (!named && !CREATIONS.has(req.op)) return void 0;
11647
11647
  const target = named ? entry.fs.resolvePath(entry.cwd, req.arg2 ?? "") : path;
11648
- const refused3 = devCreation(target, entry.cred?.());
11649
- if (!refused3) return void 0;
11648
+ const refused4 = devCreation(target, entry.cred?.());
11649
+ if (!refused4) return void 0;
11650
11650
  const there = await entry.fs.lstat(target).then(
11651
11651
  () => true,
11652
11652
  () => false
11653
11653
  );
11654
11654
  if (there) return void 0;
11655
- return { ok: false, errno: refused3, message: `${target}: no new names in /dev or /proc` };
11655
+ return { ok: false, errno: refused4, message: `${target}: no new names in /dev or /proc` };
11656
11656
  }
11657
11657
  var MISS_OPS = /* @__PURE__ */ new Set(["stat", "lstat"]);
11658
11658
  async function linkFree(fs, path) {
@@ -13107,11 +13107,11 @@ var EpollFile = class _EpollFile {
13107
13107
  const round = new AbortController();
13108
13108
  const stop = () => round.abort();
13109
13109
  signal.addEventListener("abort", stop, { once: true });
13110
- let failed3 = false;
13110
+ let failed4 = false;
13111
13111
  try {
13112
13112
  await file.changed(round.signal);
13113
13113
  } catch {
13114
- failed3 = true;
13114
+ failed4 = true;
13115
13115
  } finally {
13116
13116
  round.abort();
13117
13117
  signal.removeEventListener("abort", stop);
@@ -13119,7 +13119,7 @@ var EpollFile = class _EpollFile {
13119
13119
  if (signal.aborted) return;
13120
13120
  reg.gen++;
13121
13121
  this.changes.wake();
13122
- if (failed3) await pause(RETRY_MS, signal);
13122
+ if (failed4) await pause(RETRY_MS, signal);
13123
13123
  }
13124
13124
  }
13125
13125
  };
@@ -13755,8 +13755,8 @@ var KernelLoopback = class {
13755
13755
  );
13756
13756
  } catch (err) {
13757
13757
  socket.close();
13758
- const refused3 = err instanceof KernelError && err.code === "ECONNREFUSED";
13759
- throw refused3 ? errno2("ECONNREFUSED", `nothing listens on the kernel's port ${port}`) : err;
13758
+ const refused4 = err instanceof KernelError && err.code === "ECONNREFUSED";
13759
+ throw refused4 ? errno2("ECONNREFUSED", `nothing listens on the kernel's port ${port}`) : err;
13760
13760
  }
13761
13761
  signal.addEventListener("abort", () => socket.close(), { once: true });
13762
13762
  return socket;
@@ -15202,8 +15202,8 @@ var HttpHandles = class {
15202
15202
  if (text === NO_TRANSPORT || typeof status !== "number" || status === 502) {
15203
15203
  const code = codeOf2(e);
15204
15204
  const errno3 = text === NO_TRANSPORT ? "ENETUNREACH" : code !== "EIO" ? code : "ECONNREFUSED";
15205
- const failed3 = e.detail === "transport";
15206
- return { ok: false, errno: errno3, message: text, ...failed3 ? { detail: "transport" } : {} };
15205
+ const failed4 = e.detail === "transport";
15206
+ return { ok: false, errno: errno3, message: text, ...failed4 ? { detail: "transport" } : {} };
15207
15207
  }
15208
15208
  entry.body = once(new TextEncoder().encode(text))[Symbol.asyncIterator]();
15209
15209
  return this.headOf(handle, req.url, {
@@ -17111,23 +17111,23 @@ function scrubbed(inner, scrubber, idleMs = SCRUB_IDLE_MS) {
17111
17111
  let pending = 0;
17112
17112
  let busy = false;
17113
17113
  let timer;
17114
- let failed3;
17114
+ let failed4;
17115
17115
  const waiters = /* @__PURE__ */ new Set();
17116
17116
  const quiet3 = () => !busy && pending === 0;
17117
17117
  const wake = () => {
17118
17118
  for (const waiter of [...waiters]) waiter();
17119
17119
  };
17120
17120
  const raise = () => {
17121
- if (failed3 === void 0) return;
17122
- const err = failed3;
17123
- failed3 = void 0;
17121
+ if (failed4 === void 0) return;
17122
+ const err = failed4;
17123
+ failed4 = void 0;
17124
17124
  throw err;
17125
17125
  };
17126
17126
  const later = (bytes) => {
17127
17127
  if (bytes.length === 0) return;
17128
17128
  pending += 1;
17129
17129
  tail2 = tail2.then(() => writeAll2(file, bytes)).catch((err) => {
17130
- if (failed3 === void 0) failed3 = err;
17130
+ if (failed4 === void 0) failed4 = err;
17131
17131
  }).finally(() => {
17132
17132
  pending -= 1;
17133
17133
  if (quiet3()) wake();
@@ -25258,6 +25258,234 @@ function enableDnsStub(net, stub) {
25258
25258
  });
25259
25259
  }
25260
25260
 
25261
+ // src/kernel/net/remote-transport.ts
25262
+ var TransportError = class extends Error {
25263
+ status;
25264
+ code;
25265
+ detail;
25266
+ constructor(message3, status, code, detail) {
25267
+ super(message3);
25268
+ this.status = status;
25269
+ this.code = code;
25270
+ this.detail = detail === "transport" ? detail : void 0;
25271
+ }
25272
+ };
25273
+ function unfollowed2(redirect) {
25274
+ return redirect !== void 0 && redirect !== "follow";
25275
+ }
25276
+ function honors(traits, redirect) {
25277
+ if (traits.redirectPolicy === true) return true;
25278
+ const hops = traits.redirectHops;
25279
+ const raw2 = traits.manualRedirects === true && (hops === void 0 || hops === false);
25280
+ return redirect === "manual" && raw2;
25281
+ }
25282
+ function refused3(message3) {
25283
+ return new TransportError(message3, 502, void 0, "transport");
25284
+ }
25285
+ var RemoteTransport = class {
25286
+ traits;
25287
+ port;
25288
+ waiting = /* @__PURE__ */ new Map();
25289
+ nextId = 0;
25290
+ sockets = /* @__PURE__ */ new Map();
25291
+ uploads = /* @__PURE__ */ new Map();
25292
+ failure;
25293
+ constructor(port, traits) {
25294
+ this.port = port;
25295
+ this.traits = traits;
25296
+ }
25297
+ receive(reply) {
25298
+ if (reply.net === "body-pull") {
25299
+ void this.pull(reply.nid);
25300
+ return;
25301
+ }
25302
+ const socket = this.sockets.get(reply.nid);
25303
+ if (socket && this.toSocket(reply, socket)) return;
25304
+ const waiter = this.waiting.get(reply.nid);
25305
+ if (!waiter) return;
25306
+ this.waiting.delete(reply.nid);
25307
+ if (reply.net === "error") {
25308
+ waiter.reject(new TransportError(reply.message, reply.status, reply.code, reply.detail));
25309
+ } else waiter.resolve(reply);
25310
+ }
25311
+ toSocket(reply, socket) {
25312
+ if (reply.net === "ws-message") socket.queue.push(reply.data);
25313
+ else if (reply.net === "ws-acked") socket.acked(reply.n);
25314
+ else if (reply.net === "ws-closed") {
25315
+ this.sockets.delete(reply.nid);
25316
+ socket.queue.end({ code: reply.code, reason: reply.reason });
25317
+ } else return false;
25318
+ return true;
25319
+ }
25320
+ async pull(nid) {
25321
+ const upload = this.uploads.get(nid);
25322
+ if (!upload) {
25323
+ this.port.postMessage({ net: "body-error", nid, message: "the request body is gone" });
25324
+ return;
25325
+ }
25326
+ try {
25327
+ const next3 = await upload.next();
25328
+ if (next3.done) {
25329
+ this.uploads.delete(nid);
25330
+ this.port.postMessage({ net: "body-end", nid });
25331
+ } else this.port.postMessage({ net: "body-chunk", nid, bytes: next3.value });
25332
+ } catch (e) {
25333
+ this.uploads.delete(nid);
25334
+ this.port.postMessage({
25335
+ net: "body-error",
25336
+ nid,
25337
+ message: e instanceof Error ? e.message : String(e)
25338
+ });
25339
+ }
25340
+ }
25341
+ dropUpload(nid) {
25342
+ const upload = this.uploads.get(nid);
25343
+ this.uploads.delete(nid);
25344
+ void upload?.return?.().catch(() => void 0);
25345
+ }
25346
+ fail(error) {
25347
+ this.failure = error;
25348
+ for (const nid of [...this.uploads.keys()]) this.dropUpload(nid);
25349
+ for (const waiter of this.waiting.values()) waiter.reject(error);
25350
+ this.waiting.clear();
25351
+ for (const socket of this.sockets.values())
25352
+ socket.queue.end({ code: 1011, reason: error.message });
25353
+ this.sockets.clear();
25354
+ }
25355
+ ask(call) {
25356
+ if (this.failure) return Promise.reject(this.failure);
25357
+ return new Promise((resolve2, reject) => {
25358
+ this.waiting.set(call.nid, { resolve: resolve2, reject });
25359
+ this.port.postMessage(call);
25360
+ });
25361
+ }
25362
+ cancel(nid) {
25363
+ const waiter = this.waiting.get(nid);
25364
+ this.waiting.delete(nid);
25365
+ waiter?.reject(new TransportError("the request was cancelled"));
25366
+ this.port.postMessage({ net: "cancel", nid });
25367
+ }
25368
+ async fetch(request) {
25369
+ const nid = ++this.nextId;
25370
+ const { signal, redirect } = request;
25371
+ signal.throwIfAborted();
25372
+ if (unfollowed2(redirect) && !honors(this.traits, redirect)) {
25373
+ throw refused3(`this transport cannot honor redirect: ${redirect}`);
25374
+ }
25375
+ let finished = false;
25376
+ const abort = () => {
25377
+ finished = true;
25378
+ this.dropUpload(nid);
25379
+ this.cancel(nid);
25380
+ };
25381
+ signal.addEventListener("abort", abort, { once: true });
25382
+ const finish = () => {
25383
+ this.dropUpload(nid);
25384
+ if (finished) return;
25385
+ finished = true;
25386
+ signal.removeEventListener("abort", abort);
25387
+ };
25388
+ if (request.bodyStream) this.uploads.set(nid, request.bodyStream[Symbol.asyncIterator]());
25389
+ let head;
25390
+ try {
25391
+ head = await this.ask({
25392
+ net: "fetch",
25393
+ nid,
25394
+ url: request.url,
25395
+ method: request.method,
25396
+ headers: request.headers,
25397
+ ...request.bodyStream ? { streamed: true } : request.body ? { body: request.body } : {},
25398
+ ...redirect !== void 0 ? { redirect } : {}
25399
+ });
25400
+ } catch (e) {
25401
+ finish();
25402
+ throw e;
25403
+ }
25404
+ const { status, statusText, headers, url, redirected: redirected2, redirects, opaqueRedirect } = head;
25405
+ const read = async () => {
25406
+ if (finished) return void 0;
25407
+ const reply = await this.ask({ net: "read", nid }).catch((e) => {
25408
+ finish();
25409
+ throw e;
25410
+ });
25411
+ if (reply.net === "chunk") return reply.bytes;
25412
+ finish();
25413
+ return void 0;
25414
+ };
25415
+ const cancel = async () => {
25416
+ if (finished) return;
25417
+ finish();
25418
+ this.cancel(nid);
25419
+ };
25420
+ if (unfollowed2(redirect) && (redirected2 || redirects?.length)) {
25421
+ await cancel();
25422
+ throw refused3(`this transport followed a redirect despite redirect: ${redirect}`);
25423
+ }
25424
+ return {
25425
+ ...url !== void 0 ? { url } : {},
25426
+ ...redirected2 !== void 0 ? { redirected: redirected2 } : {},
25427
+ ...redirects ? { redirects } : {},
25428
+ ...opaqueRedirect ? { opaqueRedirect } : {},
25429
+ status,
25430
+ statusText,
25431
+ headers,
25432
+ cancel,
25433
+ body: {
25434
+ [Symbol.asyncIterator]: () => ({
25435
+ next: async () => {
25436
+ const bytes = await read();
25437
+ return bytes ? { value: bytes, done: false } : { value: void 0, done: true };
25438
+ },
25439
+ return: async () => {
25440
+ await cancel();
25441
+ return { value: void 0, done: true };
25442
+ }
25443
+ })
25444
+ }
25445
+ };
25446
+ }
25447
+ async websocket(request) {
25448
+ const nid = ++this.nextId;
25449
+ const { signal } = request;
25450
+ signal.throwIfAborted();
25451
+ const abort = () => this.cancel(nid);
25452
+ signal.addEventListener("abort", abort, { once: true });
25453
+ let opened2;
25454
+ try {
25455
+ opened2 = await this.ask({
25456
+ net: "ws-open",
25457
+ nid,
25458
+ url: request.url,
25459
+ protocols: request.protocols,
25460
+ headers: request.headers
25461
+ });
25462
+ } finally {
25463
+ signal.removeEventListener("abort", abort);
25464
+ }
25465
+ const close = (code, reason) => this.port.postMessage({ net: "ws-close", nid, code, reason });
25466
+ const queue = new MessageQueue(
25467
+ () => close(1e3, "a message is too big"),
25468
+ Number.POSITIVE_INFINITY,
25469
+ (n) => this.port.postMessage({ net: "ws-consumed", nid, n })
25470
+ );
25471
+ let unacked = 0;
25472
+ this.sockets.set(nid, { queue, acked: (n) => void (unacked -= n) });
25473
+ return {
25474
+ protocol: opened2.protocol,
25475
+ get buffered() {
25476
+ return unacked;
25477
+ },
25478
+ send: (data) => {
25479
+ unacked += payloadSize(data);
25480
+ this.port.postMessage({ net: "ws-send", nid, data });
25481
+ },
25482
+ messages: queue,
25483
+ close,
25484
+ closed: queue.closed
25485
+ };
25486
+ }
25487
+ };
25488
+
25261
25489
  // src/kernel/net/redirect-hops.ts
25262
25490
  var HELD_MS = 3e4;
25263
25491
  var HELD_MAX2 = 64;
@@ -25333,7 +25561,9 @@ function replayingHops(inner, heldMs = HELD_MS) {
25333
25561
  return { ...inner.traits, manualRedirects: true };
25334
25562
  },
25335
25563
  ...inner.websocket ? { websocket: inner.websocket.bind(inner) } : {},
25336
- async fetch(request, caller) {
25564
+ async fetch(request, ...rest2) {
25565
+ if (unfollowed2(request.redirect)) return inner.fetch(request, ...rest2);
25566
+ const [caller] = rest2;
25337
25567
  const owner = caller ?? KERNEL;
25338
25568
  const key = keyOf3(owner, request.method, request.url);
25339
25569
  const waiting = held.get(key);
@@ -25343,7 +25573,7 @@ function replayingHops(inner, heldMs = HELD_MS) {
25343
25573
  return replay(waiting);
25344
25574
  }
25345
25575
  if (waiting) drop(key);
25346
- const response = await inner.fetch(request, caller);
25576
+ const response = await inner.fetch(request, ...rest2);
25347
25577
  if (!response.redirects?.length) return response;
25348
25578
  return replay({
25349
25579
  owner,
@@ -25528,11 +25758,11 @@ var PackageLocks = class {
25528
25758
  if (!locks) return Promise.resolve(() => {
25529
25759
  });
25530
25760
  const { promise: held, resolve: release } = Promise.withResolvers();
25531
- return new Promise((granted2, failed3) => {
25761
+ return new Promise((granted2, failed4) => {
25532
25762
  locks.request(replacingLock(this.metadata, root), { mode: "exclusive" }, () => {
25533
25763
  granted2(() => release());
25534
25764
  return held;
25535
- }).catch(failed3);
25765
+ }).catch(failed4);
25536
25766
  });
25537
25767
  }
25538
25768
  };
@@ -25782,9 +26012,9 @@ function serveFilesystem(port, handlers, capabilities = {}, options = {}) {
25782
26012
  let open = false;
25783
26013
  const reply = (message3, transfer = []) => port.postMessage(message3, transfer);
25784
26014
  async function hello(message3) {
25785
- const refused3 = driverVersionError(message3.protocol);
25786
- if (refused3) {
25787
- reply({ hello: { protocol: DRIVER_PROTOCOL, error: refused3, errno: "EPROTO" } });
26015
+ const refused4 = driverVersionError(message3.protocol);
26016
+ if (refused4) {
26017
+ reply({ hello: { protocol: DRIVER_PROTOCOL, error: refused4, errno: "EPROTO" } });
25788
26018
  return;
25789
26019
  }
25790
26020
  try {
@@ -28026,12 +28256,12 @@ var OpfsFs = class {
28026
28256
  if (!move) return false;
28027
28257
  for (let attempt = 0; ; attempt++) {
28028
28258
  this.others++;
28029
- const failed3 = await move.call(handle, dir, name2).then(
28259
+ const failed4 = await move.call(handle, dir, name2).then(
28030
28260
  () => void 0,
28031
28261
  (err) => ({ err })
28032
28262
  );
28033
- if (!failed3) return true;
28034
- const error = failed3.err?.name;
28263
+ if (!failed4) return true;
28264
+ const error = failed4.err?.name;
28035
28265
  if (handle.kind !== "file" || !LOCKED.has(error)) return false;
28036
28266
  const delay2 = SYNC_BACKOFF_MS[attempt];
28037
28267
  if (delay2 === void 0) throw fsError("EBUSY", name2);
@@ -28594,22 +28824,22 @@ async function mountFstab(lines2, mount, signal, retries = FSTAB_RETRIES, discar
28594
28824
  );
28595
28825
  }
28596
28826
  async function mountLine({ line, spec, invalid }, mount, signal, retries, discard) {
28597
- let failed3 = invalid;
28827
+ let failed4 = invalid;
28598
28828
  for (let attempt = 0; !invalid && attempt <= retries.length && !signal.aborted; attempt++) {
28599
28829
  try {
28600
28830
  const entry = await mount(spec);
28601
28831
  if (!signal.aborted) return { line, target: spec.target, entry };
28602
28832
  discard(entry);
28603
- failed3 = Object.assign(new Error("the kernel stopped"), { code: "ECANCELED" });
28833
+ failed4 = Object.assign(new Error("the kernel stopped"), { code: "ECANCELED" });
28604
28834
  break;
28605
28835
  } catch (err) {
28606
- failed3 = err;
28836
+ failed4 = err;
28607
28837
  if (FINAL.has(codeOf6(err)) || attempt === retries.length) break;
28608
28838
  await wait(retries[attempt], signal);
28609
28839
  }
28610
28840
  }
28611
- const code = codeOf6(failed3);
28612
- return { line, target: spec.target, code, error: String(failed3?.message ?? code) };
28841
+ const code = codeOf6(failed4);
28842
+ return { line, target: spec.target, code, error: String(failed4?.message ?? code) };
28613
28843
  }
28614
28844
 
28615
28845
  // src/mount/hostfs.ts
@@ -31225,16 +31455,16 @@ var Launcher = class {
31225
31455
  if (!found) {
31226
31456
  found = this.swaps.settled().then(() => this.trustedAppended()).then(async (appended2) => {
31227
31457
  const tiers = await this.tiers(scope, appended2);
31228
- const refused3 = [];
31458
+ const refused4 = [];
31229
31459
  const commands = await scanCommands(
31230
31460
  this.scanned,
31231
31461
  tiers,
31232
31462
  tiers.length - appended2.length,
31233
31463
  void 0,
31234
- refused3,
31464
+ refused4,
31235
31465
  await this.globalRoots(scope)
31236
31466
  );
31237
- this.refusedOf.set(commands, refused3.map(refusing));
31467
+ this.refusedOf.set(commands, refused4.map(refusing));
31238
31468
  return commands;
31239
31469
  }).then(
31240
31470
  (commands) => this.refusals(commands).set(SUDO_COMMAND.name, SUDO_COMMAND).set(CRONTAB_COMMAND.name, CRONTAB_COMMAND)
@@ -31440,14 +31670,14 @@ var Launcher = class {
31440
31670
  return await this.commandAt(path, scope) ?? await this.refusedAt(path, name2, scope);
31441
31671
  }
31442
31672
  async refusedAt(path, name2, scope) {
31443
- const refused3 = this.refusedOf.get(await this.commands(scope)) ?? [];
31444
- if (refused3.length === 0) return void 0;
31673
+ const refused4 = this.refusedOf.get(await this.commands(scope)) ?? [];
31674
+ if (refused4.length === 0) return void 0;
31445
31675
  const st = await this.base.stat(path).catch(() => void 0);
31446
31676
  if (!st?.isFile) return void 0;
31447
31677
  const real = await physicalPathAsync(this.base, path).catch(() => path);
31448
31678
  const same2 = async (own) => own === path || await physicalPathAsync(this.base, own).catch(() => own) === real;
31449
31679
  const owners = [];
31450
- for (const c of refused3) {
31680
+ for (const c of refused4) {
31451
31681
  const origin = c.origin;
31452
31682
  for (const own of [origin.glue, origin.wasm, ...origin.variants ?? []]) {
31453
31683
  if (!await same2(own)) continue;
@@ -31457,11 +31687,11 @@ var Launcher = class {
31457
31687
  }
31458
31688
  const stem = name2.replace(/\.wasm$/, "");
31459
31689
  const named = owners.find((c) => c.name === name2) ?? owners.find((c) => c.name === stem);
31460
- return named ?? owners[0] ?? await this.refusedCopy(real, name2, refused3);
31690
+ return named ?? owners[0] ?? await this.refusedCopy(real, name2, refused4);
31461
31691
  }
31462
- async refusedCopy(real, name2, refused3) {
31692
+ async refusedCopy(real, name2, refused4) {
31463
31693
  const dir = real.slice(0, real.lastIndexOf("/"));
31464
- for (const c of refused3) {
31694
+ for (const c of refused4) {
31465
31695
  const origin = c.origin;
31466
31696
  if (origin.abi !== "emscripten" || origin.script || c.name !== name2) continue;
31467
31697
  const own = await physicalPathAsync(this.base, origin.glue).catch(() => origin.glue);
@@ -31669,12 +31899,12 @@ var Launcher = class {
31669
31899
  return void 0;
31670
31900
  }
31671
31901
  async planOne(req, { ppid, cred, scope }, catalogOnly = false) {
31672
- const refused3 = (err) => {
31902
+ const refused4 = (err) => {
31673
31903
  throw codeOf8(err) === "EACCES" ? new SpawnError("EACCES") : err;
31674
31904
  };
31675
- const file = await this.execFile(req.file, req.cwd, this.execGuard(cred, ppid)).catch(refused3);
31905
+ const file = await this.execFile(req.file, req.cwd, this.execGuard(cred, ppid)).catch(refused4);
31676
31906
  const planned = await this.plan(file, req.argv, req.cwd, scope, req.argv0, catalogOnly);
31677
- await this.mayExec(cred, { ...req, file, pid: ppid }, planned).catch(refused3);
31907
+ await this.mayExec(cred, { ...req, file, pid: ppid }, planned).catch(refused4);
31678
31908
  if (planned) return planned;
31679
31909
  throw new SpawnError(catalogOnly ? "ENOENT" : await this.unrunnable(file, req.cwd, scope));
31680
31910
  }
@@ -32962,8 +33192,8 @@ var Launcher = class {
32962
33192
  for (const name2 of names2 ?? []) {
32963
33193
  const path = joinName(real, name2);
32964
33194
  if (await this.base.hasOwner(path)) continue;
32965
- const failed3 = this.inUse(path) ? "busy" : await this.base.rm(path, { recursive: true, force: true }).catch(String);
32966
- if (failed3 === void 0) removed++;
33195
+ const failed4 = this.inUse(path) ? "busy" : await this.base.rm(path, { recursive: true, force: true }).catch(String);
33196
+ if (failed4 === void 0) removed++;
32967
33197
  else left++;
32968
33198
  }
32969
33199
  if (removed > 0) {
@@ -33756,10 +33986,11 @@ function fetchTransport(options = {}) {
33756
33986
  const send2 = options.fetch ?? globalThis.fetch.bind(globalThis);
33757
33987
  const Socket = options.webSocket === true ? globalThis.WebSocket : options.webSocket || void 0;
33758
33988
  const headers = options.webSocketHeaders === true;
33759
- const redirect = options.redirect ?? "follow";
33989
+ const instance = options.redirect ?? "follow";
33760
33990
  return {
33761
33991
  traits: {
33762
- manualRedirects: redirect === "manual",
33992
+ manualRedirects: instance === "manual",
33993
+ redirectPolicy: true,
33763
33994
  encodedBodies: false,
33764
33995
  maxRequestBody: options.maxRequestBody ?? MAX_REQUEST_BODY,
33765
33996
  crossOrigin: "cors",
@@ -33775,7 +34006,7 @@ function fetchTransport(options = {}) {
33775
34006
  headers: joinHeaders(request.headers),
33776
34007
  ...requestBody(request),
33777
34008
  signal: request.signal,
33778
- redirect,
34009
+ redirect: request.redirect ?? instance,
33779
34010
  credentials: "omit",
33780
34011
  mode: "cors"
33781
34012
  });
@@ -33799,6 +34030,7 @@ function fetchTransport(options = {}) {
33799
34030
  const body = chunks(response.body, options.bodyIdleMs ?? BODY_IDLE_MS);
33800
34031
  return {
33801
34032
  ...response.redirected ? { url: response.url, redirected: true } : {},
34033
+ ...response.type === "opaqueredirect" ? { opaqueRedirect: true } : {},
33802
34034
  status: response.status,
33803
34035
  statusText: response.statusText,
33804
34036
  headers: headers2,
@@ -33834,6 +34066,19 @@ function uploadsFor(peer) {
33834
34066
  });
33835
34067
  return { of, answer: (call) => pulls.get(call.nid)?.(call) };
33836
34068
  }
34069
+ function headOf(nid, response) {
34070
+ return {
34071
+ net: "head",
34072
+ nid,
34073
+ ...response.url !== void 0 ? { url: response.url } : {},
34074
+ ...response.redirected !== void 0 ? { redirected: response.redirected } : {},
34075
+ ...response.redirects ? { redirects: response.redirects } : {},
34076
+ ...response.opaqueRedirect ? { opaqueRedirect: true } : {},
34077
+ status: response.status,
34078
+ statusText: response.statusText,
34079
+ headers: response.headers
34080
+ };
34081
+ }
33837
34082
  function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS3 } = {}) {
33838
34083
  const open = /* @__PURE__ */ new Map();
33839
34084
  const fail3 = (nid, e) => {
@@ -33859,6 +34104,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS3 } = {})
33859
34104
  method: call.method,
33860
34105
  headers: call.headers,
33861
34106
  ...call.streamed ? { bodyStream: uploads.of(call.nid, abort.signal) } : call.body ? { body: call.body } : {},
34107
+ ...call.redirect !== void 0 ? { redirect: call.redirect } : {},
33862
34108
  signal: abort.signal
33863
34109
  });
33864
34110
  if (!open.has(call.nid)) {
@@ -33866,15 +34112,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS3 } = {})
33866
34112
  return;
33867
34113
  }
33868
34114
  open.set(call.nid, { abort, body: response.body[Symbol.asyncIterator](), response });
33869
- peer.postMessage({
33870
- net: "head",
33871
- nid: call.nid,
33872
- ...response.redirected ? { url: response.url, redirected: true } : {},
33873
- ...response.redirects ? { redirects: response.redirects } : {},
33874
- status: response.status,
33875
- statusText: response.statusText,
33876
- headers: response.headers
33877
- });
34115
+ peer.postMessage(headOf(call.nid, response));
33878
34116
  } catch (e) {
33879
34117
  fail3(call.nid, e);
33880
34118
  }
@@ -34374,9 +34612,9 @@ function serveClient(port, host) {
34374
34612
  ended.resolve();
34375
34613
  }
34376
34614
  async function hello(message3) {
34377
- const refused3 = versionError(message3.protocol) ?? await hosts.requests.accept(host, message3);
34378
- if (refused3) {
34379
- send2({ hello: { protocol: PROTOCOL, error: refused3 } });
34615
+ const refused4 = versionError(message3.protocol) ?? await hosts.requests.accept(host, message3);
34616
+ if (refused4) {
34617
+ send2({ hello: { protocol: PROTOCOL, error: refused4 } });
34380
34618
  detach();
34381
34619
  return;
34382
34620
  }
@@ -34520,6 +34758,60 @@ import { AsyncLocalStorage } from "node:async_hooks";
34520
34758
  import { subscribe } from "node:diagnostics_channel";
34521
34759
  import { lookup as lookup2 } from "node:dns/promises";
34522
34760
  import { isIP as isIP3 } from "node:net";
34761
+
34762
+ // src/node/follow.ts
34763
+ var MAX_REDIRECTS = 20;
34764
+ var REDIRECTS = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
34765
+ var BODY_HEADERS = /* @__PURE__ */ new Set([
34766
+ "content-encoding",
34767
+ "content-language",
34768
+ "content-length",
34769
+ "content-location",
34770
+ "content-type"
34771
+ ]);
34772
+ var CREDENTIALS = /* @__PURE__ */ new Set(["authorization", "proxy-authorization", "cookie", "cookie2"]);
34773
+ function failed3(message3) {
34774
+ return Object.assign(new Error(message3), { status: 502, detail: "transport" });
34775
+ }
34776
+ function locationOf(headers) {
34777
+ return headers.find(([name2]) => name2.toLowerCase() === "location")?.[1];
34778
+ }
34779
+ function nextHop(hop, status, location) {
34780
+ if (!URL.canParse(location, hop.url)) throw failed3(`a bad redirect from ${hop.url}`);
34781
+ const next3 = new URL(location, hop.url);
34782
+ if (next3.protocol !== "http:" && next3.protocol !== "https:") {
34783
+ throw failed3(`a redirect from ${hop.url} to ${next3.protocol}`);
34784
+ }
34785
+ next3.hash = "";
34786
+ const toGet = (status === 301 || status === 302) && hop.method === "POST" || status === 303 && hop.method !== "GET" && hop.method !== "HEAD";
34787
+ if (hop.bodyStream && !toGet) throw failed3(`a ${status} redirect would resend a streamed body`);
34788
+ const crossOrigin = next3.origin !== new URL(hop.url).origin;
34789
+ const { body, bodyStream: bodyStream2, ...rest2 } = hop;
34790
+ return {
34791
+ ...rest2,
34792
+ ...body && !toGet ? { body } : {},
34793
+ url: next3.href,
34794
+ method: toGet ? "GET" : hop.method,
34795
+ headers: hop.headers.filter(
34796
+ ([name2]) => !(toGet && BODY_HEADERS.has(name2.toLowerCase())) && !(crossOrigin && CREDENTIALS.has(name2.toLowerCase()))
34797
+ )
34798
+ };
34799
+ }
34800
+ async function followRedirects(send2, request) {
34801
+ let hop = { ...request, redirect: "manual" };
34802
+ for (let hops = 0; ; hops++) {
34803
+ const response = await send2(hop);
34804
+ const location = locationOf(response.headers);
34805
+ if (!REDIRECTS.has(response.status) || location === void 0) {
34806
+ return hops > 0 ? { ...response, url: hop.url, redirected: true } : response;
34807
+ }
34808
+ await response.cancel();
34809
+ if (hops >= MAX_REDIRECTS) throw failed3(`too many redirects from ${request.url}`);
34810
+ hop = nextHop(hop, response.status, location);
34811
+ }
34812
+ }
34813
+
34814
+ // src/node/loopback.ts
34523
34815
  var DEVTOOLS_PORTS = [9222, 9223, 9224, 9225, 9226, 9227, 9228, 9229];
34524
34816
  var METADATA_V6 = [64768, 3778, 0, 0, 0, 0, 0, 596].join(":");
34525
34817
  var resolveHost = async (host) => (await lookup2(host, { all: true, verbatim: true })).map((a) => a.address);
@@ -34684,19 +34976,20 @@ function ensureSubscribed() {
34684
34976
  function guardedLoopback(transport, policy, resolve2) {
34685
34977
  ensureSubscribed();
34686
34978
  const open = transport.websocket?.bind(transport);
34979
+ const send2 = async (request, owner) => {
34980
+ await guarded2(checkDestination(request.url, policy, resolve2), request.signal);
34981
+ const entry = { policy };
34982
+ try {
34983
+ return await loopbackStore.run(entry, () => transport.fetch(request, owner));
34984
+ } catch (err) {
34985
+ throw entry.refused ?? err;
34986
+ }
34987
+ };
34687
34988
  return {
34688
34989
  get traits() {
34689
34990
  return transport.traits;
34690
34991
  },
34691
- fetch: async (request, owner) => {
34692
- await guarded2(checkDestination(request.url, policy, resolve2), request.signal);
34693
- const entry = { policy };
34694
- try {
34695
- return await loopbackStore.run(entry, () => transport.fetch(request, owner));
34696
- } catch (err) {
34697
- throw entry.refused ?? err;
34698
- }
34699
- },
34992
+ fetch: (request, owner) => request.redirect === "follow" ? followRedirects((hop) => send2(hop, owner), request) : send2(request, owner),
34700
34993
  ...open ? {
34701
34994
  websocket: async (request) => {
34702
34995
  await guarded2(checkDestination(request.url, policy, resolve2), request.signal);
@@ -35082,212 +35375,6 @@ function diagnosing(transport, check = byDefault) {
35082
35375
  };
35083
35376
  }
35084
35377
 
35085
- // src/kernel/net/remote-transport.ts
35086
- var TransportError = class extends Error {
35087
- status;
35088
- code;
35089
- detail;
35090
- constructor(message3, status, code, detail) {
35091
- super(message3);
35092
- this.status = status;
35093
- this.code = code;
35094
- this.detail = detail === "transport" ? detail : void 0;
35095
- }
35096
- };
35097
- var RemoteTransport = class {
35098
- traits;
35099
- port;
35100
- waiting = /* @__PURE__ */ new Map();
35101
- nextId = 0;
35102
- sockets = /* @__PURE__ */ new Map();
35103
- uploads = /* @__PURE__ */ new Map();
35104
- failure;
35105
- constructor(port, traits) {
35106
- this.port = port;
35107
- this.traits = traits;
35108
- }
35109
- receive(reply) {
35110
- if (reply.net === "body-pull") {
35111
- void this.pull(reply.nid);
35112
- return;
35113
- }
35114
- const socket = this.sockets.get(reply.nid);
35115
- if (socket && this.toSocket(reply, socket)) return;
35116
- const waiter = this.waiting.get(reply.nid);
35117
- if (!waiter) return;
35118
- this.waiting.delete(reply.nid);
35119
- if (reply.net === "error") {
35120
- waiter.reject(new TransportError(reply.message, reply.status, reply.code, reply.detail));
35121
- } else waiter.resolve(reply);
35122
- }
35123
- toSocket(reply, socket) {
35124
- if (reply.net === "ws-message") socket.queue.push(reply.data);
35125
- else if (reply.net === "ws-acked") socket.acked(reply.n);
35126
- else if (reply.net === "ws-closed") {
35127
- this.sockets.delete(reply.nid);
35128
- socket.queue.end({ code: reply.code, reason: reply.reason });
35129
- } else return false;
35130
- return true;
35131
- }
35132
- async pull(nid) {
35133
- const upload = this.uploads.get(nid);
35134
- if (!upload) {
35135
- this.port.postMessage({ net: "body-error", nid, message: "the request body is gone" });
35136
- return;
35137
- }
35138
- try {
35139
- const next3 = await upload.next();
35140
- if (next3.done) {
35141
- this.uploads.delete(nid);
35142
- this.port.postMessage({ net: "body-end", nid });
35143
- } else this.port.postMessage({ net: "body-chunk", nid, bytes: next3.value });
35144
- } catch (e) {
35145
- this.uploads.delete(nid);
35146
- this.port.postMessage({
35147
- net: "body-error",
35148
- nid,
35149
- message: e instanceof Error ? e.message : String(e)
35150
- });
35151
- }
35152
- }
35153
- dropUpload(nid) {
35154
- const upload = this.uploads.get(nid);
35155
- this.uploads.delete(nid);
35156
- void upload?.return?.().catch(() => void 0);
35157
- }
35158
- fail(error) {
35159
- this.failure = error;
35160
- for (const nid of [...this.uploads.keys()]) this.dropUpload(nid);
35161
- for (const waiter of this.waiting.values()) waiter.reject(error);
35162
- this.waiting.clear();
35163
- for (const socket of this.sockets.values())
35164
- socket.queue.end({ code: 1011, reason: error.message });
35165
- this.sockets.clear();
35166
- }
35167
- ask(call) {
35168
- if (this.failure) return Promise.reject(this.failure);
35169
- return new Promise((resolve2, reject) => {
35170
- this.waiting.set(call.nid, { resolve: resolve2, reject });
35171
- this.port.postMessage(call);
35172
- });
35173
- }
35174
- cancel(nid) {
35175
- const waiter = this.waiting.get(nid);
35176
- this.waiting.delete(nid);
35177
- waiter?.reject(new TransportError("the request was cancelled"));
35178
- this.port.postMessage({ net: "cancel", nid });
35179
- }
35180
- async fetch(request) {
35181
- const nid = ++this.nextId;
35182
- const { signal } = request;
35183
- signal.throwIfAborted();
35184
- let finished = false;
35185
- const abort = () => {
35186
- finished = true;
35187
- this.dropUpload(nid);
35188
- this.cancel(nid);
35189
- };
35190
- signal.addEventListener("abort", abort, { once: true });
35191
- const finish = () => {
35192
- this.dropUpload(nid);
35193
- if (finished) return;
35194
- finished = true;
35195
- signal.removeEventListener("abort", abort);
35196
- };
35197
- if (request.bodyStream) this.uploads.set(nid, request.bodyStream[Symbol.asyncIterator]());
35198
- let head;
35199
- try {
35200
- head = await this.ask({
35201
- net: "fetch",
35202
- nid,
35203
- url: request.url,
35204
- method: request.method,
35205
- headers: request.headers,
35206
- ...request.bodyStream ? { streamed: true } : request.body ? { body: request.body } : {}
35207
- });
35208
- } catch (e) {
35209
- finish();
35210
- throw e;
35211
- }
35212
- const { status, statusText, headers, url, redirected: redirected2, redirects } = head;
35213
- const read = async () => {
35214
- if (finished) return void 0;
35215
- const reply = await this.ask({ net: "read", nid }).catch((e) => {
35216
- finish();
35217
- throw e;
35218
- });
35219
- if (reply.net === "chunk") return reply.bytes;
35220
- finish();
35221
- return void 0;
35222
- };
35223
- const cancel = async () => {
35224
- if (finished) return;
35225
- finish();
35226
- this.cancel(nid);
35227
- };
35228
- return {
35229
- ...redirected2 ? { url, redirected: redirected2 } : {},
35230
- ...redirects ? { redirects } : {},
35231
- status,
35232
- statusText,
35233
- headers,
35234
- cancel,
35235
- body: {
35236
- [Symbol.asyncIterator]: () => ({
35237
- next: async () => {
35238
- const bytes = await read();
35239
- return bytes ? { value: bytes, done: false } : { value: void 0, done: true };
35240
- },
35241
- return: async () => {
35242
- await cancel();
35243
- return { value: void 0, done: true };
35244
- }
35245
- })
35246
- }
35247
- };
35248
- }
35249
- async websocket(request) {
35250
- const nid = ++this.nextId;
35251
- const { signal } = request;
35252
- signal.throwIfAborted();
35253
- const abort = () => this.cancel(nid);
35254
- signal.addEventListener("abort", abort, { once: true });
35255
- let opened2;
35256
- try {
35257
- opened2 = await this.ask({
35258
- net: "ws-open",
35259
- nid,
35260
- url: request.url,
35261
- protocols: request.protocols,
35262
- headers: request.headers
35263
- });
35264
- } finally {
35265
- signal.removeEventListener("abort", abort);
35266
- }
35267
- const close = (code, reason) => this.port.postMessage({ net: "ws-close", nid, code, reason });
35268
- const queue = new MessageQueue(
35269
- () => close(1e3, "a message is too big"),
35270
- Number.POSITIVE_INFINITY,
35271
- (n) => this.port.postMessage({ net: "ws-consumed", nid, n })
35272
- );
35273
- let unacked = 0;
35274
- this.sockets.set(nid, { queue, acked: (n) => void (unacked -= n) });
35275
- return {
35276
- protocol: opened2.protocol,
35277
- get buffered() {
35278
- return unacked;
35279
- },
35280
- send: (data) => {
35281
- unacked += payloadSize(data);
35282
- this.port.postMessage({ net: "ws-send", nid, data });
35283
- },
35284
- messages: queue,
35285
- close,
35286
- closed: queue.closed
35287
- };
35288
- }
35289
- };
35290
-
35291
35378
  // src/serve.ts
35292
35379
  function signalNumber(name2) {
35293
35380
  const key = name2.slice(3);
@@ -35921,9 +36008,9 @@ async function greet(channel, lock, timeoutMs, requests) {
35921
36008
  } finally {
35922
36009
  clearTimeout(timer);
35923
36010
  }
35924
- const refused3 = hello.error ?? versionError(hello.protocol);
35925
- if (refused3) {
35926
- const error = new Error(refused3);
36011
+ const refused4 = hello.error ?? versionError(hello.protocol);
36012
+ if (refused4) {
36013
+ const error = new Error(refused4);
35927
36014
  channel.end(error);
35928
36015
  throw error;
35929
36016
  }