@shetty4l/core 0.1.18 → 0.1.20

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/package.json +1 -1
  2. package/src/daemon.ts +19 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shetty4l/core",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Shared infrastructure primitives for Bun/TypeScript services",
5
5
  "repository": {
6
6
  "type": "git",
package/src/daemon.ts CHANGED
@@ -7,7 +7,14 @@
7
7
  * No console output — returns structured results for the caller to log.
8
8
  */
9
9
 
10
- import { existsSync, mkdirSync, readFileSync, unlinkSync } from "fs";
10
+ import {
11
+ closeSync,
12
+ existsSync,
13
+ mkdirSync,
14
+ openSync,
15
+ readFileSync,
16
+ unlinkSync,
17
+ } from "fs";
11
18
  import { join } from "path";
12
19
  import type { Result } from "./result";
13
20
  import { err, ok } from "./result";
@@ -153,12 +160,21 @@ export function createDaemonManager(opts: DaemonManagerOpts): DaemonManager {
153
160
  mkdirSync(configDir, { recursive: true });
154
161
  }
155
162
 
163
+ // Open log file in append mode so previous content is preserved
164
+ // and ongoing console.error output from the child is captured.
165
+ // Bun.file() opens with O_WRONLY|O_CREAT (no append, no truncate)
166
+ // which writes from offset 0 and corrupts logs.
167
+ const logFd = openSync(logFile, "a");
168
+
156
169
  const proc = Bun.spawn(["bun", "run", cliPath, serveCommand], {
157
- stdout: Bun.file(logFile),
158
- stderr: Bun.file(logFile),
170
+ stdout: logFd,
171
+ stderr: logFd,
159
172
  stdin: "ignore",
160
173
  });
161
174
 
175
+ // Child inherits its own copy of the fd; parent can close safely.
176
+ closeSync(logFd);
177
+
162
178
  writePid(pidFile, proc.pid);
163
179
 
164
180
  if (healthUrl) {