bm2 1.0.38 → 1.0.39

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bm2",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "description": "A blazing-fast, full-featured process manager built entirely on Bun native APIs. The modern PM2 replacement — zero Node.js dependencies, pure Bun performance.",
5
5
  "main": "src/api.ts",
6
6
  "module": "src/api.ts",
package/src/daemon.ts CHANGED
@@ -48,6 +48,7 @@ export default class Daemon {
48
48
  getServerOpts = () => ({
49
49
  unix: DAEMON_SOCKET,
50
50
  fetch: this.boundFetch,
51
+ idleTimeout: 0
51
52
  });
52
53
 
53
54
 
@@ -127,8 +128,13 @@ export default class Daemon {
127
128
 
128
129
  self.handleStreamMessage(msg, controller, signal);
129
130
 
131
+ const keepAlive = setInterval(() => {
132
+ controller.enqueue(': ping\n\n'); // SSE comment – ignored by clients but counts as data
133
+ }, 5000); // every 5 seconds (less than 10s timeout)
134
+
130
135
  // cleanup when client disconnects
131
136
  signal.addEventListener("abort", () => {
137
+ clearInterval(keepAlive)
132
138
  controller.close();
133
139
  });
134
140
  },
@@ -150,7 +156,7 @@ export default class Daemon {
150
156
  throw new Error("Daemon.initialize() must be called before startServer()");
151
157
  }
152
158
 
153
- this.server = Bun.serve(this.getServerOpts());
159
+ this.server = Bun.serve(this.getServerOpts() as any);
154
160
  return this.server;
155
161
  }
156
162
 
package/src/index.ts CHANGED
@@ -209,7 +209,8 @@ class BM2CLI {
209
209
  try {
210
210
  const result = JSON.parse(line) as T;
211
211
  callback(result)
212
- } catch {}
212
+ } catch { }
213
+
213
214
  }
214
215
  }
215
216
 
@@ -186,6 +186,7 @@ export class LogManager {
186
186
  out: Bun.file(paths.outFile).size,
187
187
  err: Bun.file(paths.errFile).size,
188
188
  };
189
+
189
190
 
190
191
  const poll = setInterval(async () => {
191
192
  for (const [type, fp] of [["out", paths.outFile],["err", paths.errFile],] as const) {
@@ -209,8 +210,13 @@ export class LogManager {
209
210
  state[type] = size;
210
211
 
211
212
  for (const line of chunk.split("\n").filter(Boolean)) {
212
- const log = { name, id, ...this.parseLine(line, type) };
213
- streamController.enqueue(`data: ${JSON.stringify(log)}\n\n`);
213
+ try {
214
+ const log = { name, id, ...this.parseLine(line, type) };
215
+ streamController.enqueue(`data: ${JSON.stringify(log)}\n\n`);
216
+ } catch (e: any) {
217
+ console.log("tailLog: ", e, e.stack)
218
+ return;
219
+ }
214
220
  }
215
221
  }
216
222
  }, 500);