Browse Source

fix(companion): guard child.pid against undefined in PID file write

Michael Henke 1 month ago
parent
commit
a82f0d84e1
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/companion/manager.ts

+ 4 - 2
src/companion/manager.ts

@@ -415,8 +415,10 @@ export class CompanionManager {
         }),
       );
       try {
-        mkdirSync(path.dirname(pidFile), { recursive: true });
-        writeFileSync(pidFile, String(child.pid));
+        if (child.pid != null) {
+          mkdirSync(path.dirname(pidFile), { recursive: true });
+          writeFileSync(pidFile, String(child.pid));
+        }
       } catch {}
     } catch (err) {
       log('[companion] spawn failed', String(err));