Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/daemon-optional-arg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"coordinate": patch
---

Fix the compiled daemon failing to start with `expected string at $[0], got null`. The library hands an absent optional positional over as null, and the native binary's type claim rejects it before the string cast; the daemon handler now normalizes the slot before indexing.
6 changes: 5 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@
};
repaint();
for (;;) {
await new Promise((res) => setTimeout(res, 1000));

Check warning on line 352 in src/main.ts

View workflow job for this annotation

GitHub Actions / oxlint

eslint(no-await-in-loop)

src/main.ts:352:7: Unexpected `await` inside a loop.
repaint();
}
}
Expand Down Expand Up @@ -408,7 +408,7 @@
}
}
for (;;) {
await new Promise((res) => setTimeout(res, 500));

Check warning on line 411 in src/main.ts

View workflow job for this annotation

GitHub Actions / oxlint

eslint(no-await-in-loop)

src/main.ts:411:7: Unexpected `await` inside a loop.
for (const p of Object.keys(offsets)) {
const size = fileSizeOf(p);
if (size > offsets[p]) {
Expand Down Expand Up @@ -548,7 +548,7 @@
// not a heavy tool: transparent passthrough, no lease round-trip (D4)
process.exit(await runChild());
}
const { slotLimit } = await import("./config.ts");

Check warning on line 551 in src/main.ts

View workflow job for this annotation

GitHub Actions / oxlint

eslint(no-shadow)

src/main.ts:551:11: 'slotLimit' is already declared in the upper scope.
// Machine keys follow the machine cap, other keys the static slot table.
const limit = key.startsWith("machine:") ? q.leaseLimit(db, key) : slotLimit(key);
if (cost > limit) {
Expand Down Expand Up @@ -580,7 +580,7 @@
const waitId = q.enqueueWait(db, key, owner, cost, deadlineAt);
process.stderr.write("coordinate run: waiting for " + key + " (wait " + waitId + ")\n");
for (;;) {
await new Promise((res) => setTimeout(res, 150));

Check warning on line 583 in src/main.ts

View workflow job for this annotation

GitHub Actions / oxlint

eslint(no-await-in-loop)

src/main.ts:583:7: Unexpected `await` inside a loop.
{
using _tx = q.writeTx(db);
q.maintainLeases(db, [key]);
Expand Down Expand Up @@ -650,7 +650,7 @@
printMsgs();
// oxlint-disable-next-line no-unmodified-loop-condition -- follow mode is an intentional forever-loop ended by signals
while (followInbox) {
await new Promise((res) => setTimeout(res, 300));

Check warning on line 653 in src/main.ts

View workflow job for this annotation

GitHub Actions / oxlint

eslint(no-await-in-loop)

src/main.ts:653:5: Unexpected `await` inside a loop.
printMsgs();
}
}
Expand All @@ -677,7 +677,7 @@
// oxlint-disable-next-line no-unmodified-loop-condition -- follow mode is an intentional forever-loop ended by signals
while (follow) {
printRows(fetchRows());
await new Promise((res) => setTimeout(res, 500));

Check warning on line 680 in src/main.ts

View workflow job for this annotation

GitHub Actions / oxlint

eslint(no-await-in-loop)

src/main.ts:680:5: Unexpected `await` inside a loop.
}
}

Expand Down Expand Up @@ -777,7 +777,7 @@

// A sub-verb handler shape: the parsed opts plus the tokens after the sub
// verb (some sub-verbs keep bespoke parsing, see the API-SWAP notes).
type Sub = (db: Database, o: Record<string, unknown>, rest: string[]) => void | Promise<void>;

Check warning on line 780 in src/main.ts

View workflow job for this annotation

GitHub Actions / oxlint

eslint(no-unused-vars)

src/main.ts:780:6: Type alias 'Sub' is declared but never used.

// ---------------------------------------------------------------- dispatch
// The library owns the verb seam: every command node below declares its
Expand Down Expand Up @@ -1117,7 +1117,11 @@
cmds["daemon"] = command("runs the claim loop on this machine", {
args: [{ name: "action", description: "restart: hand off to the current binary", optional: true }],
handler: (o: unknown, a: unknown[]) => {
return cmdDaemon(a as string[]);
// An optional arg absent from the argv arrives as null on the native
// path (the type claim rejects it before the string cast would), so
// normalize here before the rest[] index.
const rest = a.map((x) => (typeof x === "string" ? x : ""));
return cmdDaemon(rest);
},
}) as unknown as CommandDef;

Expand Down Expand Up @@ -1190,7 +1194,7 @@
// reap dead owners, drain the FIFO), so any active waiter is its own
// granter and no daemon is required for fairness.
for (;;) {
await new Promise((res) => setTimeout(res, 150));

Check warning on line 1197 in src/main.ts

View workflow job for this annotation

GitHub Actions / oxlint

eslint(no-await-in-loop)

src/main.ts:1197:5: Unexpected `await` inside a loop.
{
using _tx = q.writeTx(db);
q.maintainLeases(db, [key]);
Expand Down
Loading