@impz/testing 6.11.4 → 6.11.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.
Files changed (2) hide show
  1. package/dist/index.js +73 -28
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -22009,7 +22009,7 @@ import { join as join48 } from "path";
22009
22009
  // packages/daemon/package.json
22010
22010
  var package_default = {
22011
22011
  name: "@impz/daemon",
22012
- version: "6.11.4",
22012
+ version: "6.11.6",
22013
22013
  private: true,
22014
22014
  description: "impd: the imp host daemon",
22015
22015
  type: "module",
@@ -27666,7 +27666,7 @@ async function sendThaw(vsockPath) {
27666
27666
  decodeAgentMessage(OKSchema, response);
27667
27667
  }
27668
27668
  function readFrameWithin(connection, wait) {
27669
- return requireWithin(connection.next(), wait.timeoutMs, () => new AgentWaitError(`agent at ${wait.vsockPath} sent no ${wait.call} within ${String(wait.timeoutMs)} ms`));
27669
+ return requireWithin(connection.next(), wait.timeoutMs, () => new AgentWaitError(`agent at ${wait.vsockPath} sent no ${wait.call} within ${String(wait.timeoutMs)} ms`), wait.startTimer);
27670
27670
  }
27671
27671
 
27672
27672
  // packages/daemon/src/imps/imps/consistent-disk.ts
@@ -35146,7 +35146,7 @@ var PROXY_VARIABLE = "HTTPS_PROXY";
35146
35146
  // packages/daemon/src/vm/agent-client/exec-stream.ts
35147
35147
  import { isMessage as isMessage2 } from "@bufbuild/protobuf";
35148
35148
  var EXEC_START_TIMEOUT_MS = 1e4;
35149
- async function openExecStream(vsockPath, request, startTimeoutMs = EXEC_START_TIMEOUT_MS) {
35149
+ async function openExecStream(vsockPath, request, startTimeoutMs = EXEC_START_TIMEOUT_MS, startTimer = startRealTimer) {
35150
35150
  const { argv, env, resumeFrom, outer, require: _checked, ...rest } = request;
35151
35151
  const op = outer === true ? "exec.outer" : "exec";
35152
35152
  const opening = openStream(vsockPath, {
@@ -35155,7 +35155,7 @@ async function openExecStream(vsockPath, request, startTimeoutMs = EXEC_START_TI
35155
35155
  argv: [...argv],
35156
35156
  ...env !== undefined && { env: [...env] },
35157
35157
  ...resumeFrom !== undefined && { resumeFrom }
35158
- }, startTimeoutMs);
35158
+ }, startTimeoutMs, startTimer);
35159
35159
  const stream = await (outer === true ? opening.catch(handleUnknownOp("outer-exec")) : opening);
35160
35160
  if (request.session !== undefined && stream.session === null) {
35161
35161
  stream.close();
@@ -35178,7 +35178,7 @@ function openAttachStream(vsockPath, request, startTimeoutMs = EXEC_START_TIMEOU
35178
35178
  ...resumeFrom !== undefined && { resumeFrom }
35179
35179
  }, startTimeoutMs).catch(handleUnknownOp("sessions"));
35180
35180
  }
35181
- async function openStream(vsockPath, request, startTimeoutMs) {
35181
+ async function openStream(vsockPath, request, startTimeoutMs, startTimer = startRealTimer) {
35182
35182
  const connection = await openAgentConnection(vsockPath);
35183
35183
  let started;
35184
35184
  let output;
@@ -35187,7 +35187,8 @@ async function openStream(vsockPath, request, startTimeoutMs) {
35187
35187
  const first = await readFrameWithin(connection, {
35188
35188
  call: `${request.op} start`,
35189
35189
  vsockPath,
35190
- timeoutMs: startTimeoutMs
35190
+ timeoutMs: startTimeoutMs,
35191
+ startTimer
35191
35192
  });
35192
35193
  if (first === null) {
35193
35194
  throw new Error("agent closed the exec connection before the process started");
@@ -42986,7 +42987,8 @@ function createImpContext(deps) {
42986
42987
  const clock = {
42987
42988
  now,
42988
42989
  sleep: deps.sleep,
42989
- sleepTiming: deps.sleepTiming
42990
+ sleepTiming: deps.sleepTiming,
42991
+ execStartTimer: deps.execStartTimer ?? startRealTimer
42990
42992
  };
42991
42993
  const vms = {
42992
42994
  images: deps.images,
@@ -43866,6 +43868,7 @@ function startNewLogTap(context, imp, stream) {
43866
43868
 
43867
43869
  // packages/daemon/src/imps/imps/imp-runtime.ts
43868
43870
  var INNER_PING_TIMEOUT_MS = 1000;
43871
+ var BUILDER_EXEC_START_TIMEOUT_MS = 30000;
43869
43872
  function createImpRuntime(parts) {
43870
43873
  const context = parts.context;
43871
43874
  const lock = parts.lock;
@@ -43983,7 +43986,7 @@ function createImpRuntime(parts) {
43983
43986
  openBuilderExec: (name, request) => openStream({
43984
43987
  name,
43985
43988
  kind: "exec",
43986
- open: (paths) => openExecStream(paths.vsockSocket, request),
43989
+ open: (paths) => openExecStream(paths.vsockSocket, request, BUILDER_EXEC_START_TIMEOUT_MS, context.execStartTimer),
43987
43990
  wake: true,
43988
43991
  isBuilderAllowed: true
43989
43992
  }),
@@ -47585,7 +47588,10 @@ function resolveImpBoundaries(boundaries) {
47585
47588
  readNetBytes: boundaries.readNetBytes ?? ((tap) => readGuestNetBytes(tap)),
47586
47589
  readHostLoad: boundaries.readHostLoad ?? (() => readHostLoad({ procRoot: "/proc", readFile: readText, logger: getImpdLogger("imps") })),
47587
47590
  ...boundaries.openTap !== undefined && { openTap: boundaries.openTap },
47588
- ...boundaries.now !== undefined && { now: boundaries.now }
47591
+ ...boundaries.now !== undefined && { now: boundaries.now },
47592
+ ...boundaries.execStartTimer !== undefined && {
47593
+ execStartTimer: boundaries.execStartTimer
47594
+ }
47589
47595
  };
47590
47596
  }
47591
47597
  function makeStandInVmRam(readRam) {
@@ -49998,7 +50004,7 @@ class GuestOutputError extends Error {
49998
50004
  function createGuestExec(open, startTimer = startRealTimer) {
49999
50005
  return async (argv, options) => {
50000
50006
  options.signal.throwIfAborted();
50001
- const stream = await open({ argv: [...argv], tty: false, user: "0" });
50007
+ const stream = await openUntilAborted(open({ argv: [...argv], tty: false, user: "0" }), options.signal);
50002
50008
  if (options.signal.aborted) {
50003
50009
  stream.close();
50004
50010
  options.signal.throwIfAborted();
@@ -50058,6 +50064,27 @@ function createGuestExec(open, startTimer = startRealTimer) {
50058
50064
  }
50059
50065
  };
50060
50066
  }
50067
+ async function openUntilAborted(opening, signal) {
50068
+ const aborted = Promise.withResolvers();
50069
+ const rejectOnAbort = () => {
50070
+ aborted.reject(signal.reason);
50071
+ };
50072
+ signal.addEventListener("abort", rejectOnAbort, { once: true });
50073
+ try {
50074
+ return await Promise.race([opening, aborted.promise]);
50075
+ } catch (error) {
50076
+ if (signal.aborted) {
50077
+ closeOnceOpen(opening);
50078
+ }
50079
+ throw error;
50080
+ } finally {
50081
+ signal.removeEventListener("abort", rejectOnAbort);
50082
+ }
50083
+ }
50084
+ async function closeOnceOpen(opening) {
50085
+ const stream = await opening.catch(() => null);
50086
+ stream?.close();
50087
+ }
50061
50088
  async function sendStdin(stream, path, signal) {
50062
50089
  try {
50063
50090
  for await (const chunk of Bun.file(path).stream()) {
@@ -50097,7 +50124,8 @@ function pickRandomBuilderName() {
50097
50124
  return `imp-build-${[...picks].map((pick) => NAME_ALPHABET2[pick % NAME_ALPHABET2.length]).join("")}`;
50098
50125
  }
50099
50126
  async function waitForEngine(exec, signal, clock) {
50100
- const deadline = clock.now() + ENGINE_READY_MS;
50127
+ const startedMs = clock.now();
50128
+ const deadline = startedMs + ENGINE_READY_MS;
50101
50129
  for (;; ) {
50102
50130
  const info = await exec(["docker", "info", "--format", "{{.ServerVersion}}"], {
50103
50131
  signal,
@@ -50112,8 +50140,9 @@ async function waitForEngine(exec, signal, clock) {
50112
50140
  return;
50113
50141
  }
50114
50142
  if (clock.now() > deadline) {
50143
+ const waitedS = Math.floor((clock.now() - startedMs) / 1000);
50115
50144
  const log = await readEngineLog(exec, signal);
50116
- throw new Error(`the builder's engine did not answer in ${String(ENGINE_READY_MS / 1000)} s: ${info.stderr.trim()}${log}`);
50145
+ throw new Error(`the builder's engine did not answer in ${String(waitedS)} s: ${info.stderr.trim()}${log}`);
50117
50146
  }
50118
50147
  await clock.sleep(ENGINE_POLL_MS);
50119
50148
  }
@@ -53560,6 +53589,33 @@ function createTailnetAccess(config, deps, readStatus) {
53560
53589
  };
53561
53590
  }
53562
53591
 
53592
+ // packages/daemon/src/create-write-work.ts
53593
+ function createWriteWork() {
53594
+ const pending = new Set;
53595
+ const track = async (work) => {
53596
+ pending.add(work);
53597
+ try {
53598
+ await work;
53599
+ } catch (error) {
53600
+ getImpdLogger("events").warning("could not follow a database write: {error}", {
53601
+ error: getErrorMessage(error)
53602
+ });
53603
+ } finally {
53604
+ pending.delete(work);
53605
+ }
53606
+ };
53607
+ return {
53608
+ run: (work) => {
53609
+ if (work !== undefined) {
53610
+ track(work);
53611
+ }
53612
+ },
53613
+ stop: async () => {
53614
+ await Promise.allSettled(pending);
53615
+ }
53616
+ };
53617
+ }
53618
+
53563
53619
  // packages/daemon/src/identity/token.ts
53564
53620
  import { existsSync as existsSync21, readFileSync as readFileSync27, writeFileSync as writeFileSync9 } from "fs";
53565
53621
  import { join as join34 } from "path";
@@ -60241,32 +60297,21 @@ async function startImpdParts(config, boundaries, plan) {
60241
60297
  const governor = governed.governor;
60242
60298
  const identity = governed.identity;
60243
60299
  plan.imps = imps;
60244
- const writeWork = new Set;
60245
- const runWriteWork = async (work) => {
60246
- if (work === undefined) {
60247
- return;
60248
- }
60249
- writeWork.add(work);
60250
- try {
60251
- await work;
60252
- } finally {
60253
- writeWork.delete(work);
60254
- }
60255
- };
60300
+ const writeWork = createWriteWork();
60256
60301
  const unsubscribeWrites = db.log.subscribe((event) => {
60257
60302
  if (isUsageChange(event)) {
60258
60303
  diskUsage.requestRefresh();
60259
60304
  }
60260
60305
  if (isImpSetChange(event)) {
60261
- runWriteWork(proxyHolder.proxy?.syncListeners());
60262
- runWriteWork(broker.applyGrants());
60263
- runWriteWork(namesHolder.names?.trySync());
60306
+ writeWork.run(proxyHolder.proxy?.syncListeners());
60307
+ writeWork.run(broker.applyGrants());
60308
+ writeWork.run(namesHolder.names?.trySync());
60264
60309
  }
60265
60310
  });
60266
60311
  const dbWrites = {
60267
60312
  stop: async () => {
60268
60313
  unsubscribeWrites();
60269
- await Promise.allSettled(writeWork);
60314
+ await writeWork.stop();
60270
60315
  }
60271
60316
  };
60272
60317
  plan.dbWrites = dbWrites;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@impz/testing",
3
- "version": "6.11.4",
3
+ "version": "6.11.6",
4
4
  "description": "A real impd on stand-ins, for Bun tests of code that drives impd through @impz/client",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -43,7 +43,7 @@
43
43
  "ts-pattern": "^5.9.2",
44
44
  "xstate": "^5.33.3",
45
45
  "zod": "^4.6.7",
46
- "@impz/client": "6.11.4"
46
+ "@impz/client": "6.11.6"
47
47
  },
48
48
  "engines": {
49
49
  "bun": ">=1.4.3"