kernelpm 0.1.8 → 0.1.9

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/daemon.js +20 -8
  2. package/package.json +1 -1
package/dist/daemon.js CHANGED
@@ -82,16 +82,28 @@ class Daemon {
82
82
  }
83
83
  async init() {
84
84
  await this.store.init();
85
- for (const meta of this.store.list()) {
86
- if (meta.status === 'exited')
87
- continue;
85
+ const metas = this.store.list().filter((m) => m.status !== 'exited');
86
+ // Kick off all session recoveries concurrently WITHOUT awaiting: the
87
+ // control socket must open immediately so the broker can connect, and a
88
+ // slow / stuck `opencode serve` (one that never becomes healthy) must not
89
+ // keep the daemon from coming up — otherwise `kernelpm daemon start` polls
90
+ // its readiness window, sees no socket, and reports "did not come up in
91
+ // time" even though the daemon is still busy reattaching. A session that
92
+ // fails to recover is marked 'exited' so the app sees the truth instead of
93
+ // a perpetual 'starting'.
94
+ for (const meta of metas) {
88
95
  const session = this.spawn(meta);
89
- try {
90
- await session.start(true); // reattach if alive, resume if not
91
- }
92
- catch (err) {
96
+ void session
97
+ .start(true)
98
+ .catch(async (err) => {
93
99
  console.error(`[kernelpm] could not recover session ${meta.id}:`, err);
94
- }
100
+ try {
101
+ await this.store.upsert({ ...meta, status: 'exited', updatedAt: Date.now() });
102
+ }
103
+ catch {
104
+ /* best-effort — store may already be in a bad state */
105
+ }
106
+ });
95
107
  }
96
108
  }
97
109
  list() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kernelpm",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "kernelpm daemon — keeps opencode sessions alive on a server (via `opencode serve`) and exposes them over a local control socket.",
5
5
  "license": "MIT",
6
6
  "bin": {