Skip to content

Commit dbfba98

Browse files
committed
fix: prevent daemon startup hang and bump version to 0.0.56
1 parent b54ac97 commit dbfba98

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ode",
3-
"version": "0.0.55",
3+
"version": "0.0.56",
44
"description": "Coding anywhere with your coding agents connected",
55
"module": "packages/core/index.ts",
66
"type": "module",

packages/core/cli.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ const CLI_ENTRY = new URL(import.meta.url).pathname;
1616
const BUN_EXECUTABLE: string = process.argv[0] ?? process.execPath;
1717
const READY_WAIT_MS = 2 * 60 * 1000;
1818
const READY_POLL_MS = 500;
19+
const DAEMON_SPAWN_THROTTLE_MS = 3000;
1920
const LOG_TAIL_BYTES = 200_000;
2021
const LOG_TAIL_LINES = 40;
22+
let lastDaemonSpawnAttemptAt = 0;
2123

2224
const foregroundRequested = rawArgs.includes("--foreground");
2325
const args = foregroundRequested
@@ -93,6 +95,9 @@ function runtimeRunning(state: DaemonState = daemonState()): boolean {
9395
function ensureDaemonRunning(): void {
9496
const state = daemonState();
9597
if (managerRunning(state)) return;
98+
const now = Date.now();
99+
if (now - lastDaemonSpawnAttemptAt < DAEMON_SPAWN_THROTTLE_MS) return;
100+
lastDaemonSpawnAttemptAt = now;
96101
const child = spawn(BUN_EXECUTABLE, [CLI_ENTRY, "daemon"], {
97102
detached: true,
98103
stdio: "ignore",
@@ -210,7 +215,7 @@ if (args.includes("--help") || args.includes("-h")) {
210215

211216
if (command === "__runtime") {
212217
await import("./index");
213-
process.exit(0);
218+
await new Promise(() => {});
214219
}
215220

216221
if (command === "daemon") {
@@ -250,7 +255,7 @@ if (command === "start") {
250255

251256
if (foregroundRequested) {
252257
await import("./index");
253-
process.exit(0);
258+
await new Promise(() => {});
254259
}
255260

256261
await startBackground();

0 commit comments

Comments
 (0)