@pylonsync/functions 0.3.259 → 0.3.261
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 +1 -1
- package/src/runtime.ts +22 -6
package/package.json
CHANGED
package/src/runtime.ts
CHANGED
|
@@ -942,12 +942,12 @@ async function main() {
|
|
|
942
942
|
(f) => f.endsWith(".ts") || f.endsWith(".js")
|
|
943
943
|
);
|
|
944
944
|
} catch {
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
945
|
+
// No `functions/` directory. Legitimate for a pure-SSR app (file-based
|
|
946
|
+
// `app/**/page.tsx` routes + entity CRUD, no server functions) — the host
|
|
947
|
+
// still spawns this runner to execute SSR renders. Load zero functions and
|
|
948
|
+
// fall through so we send `ready` AND start the reader loop; returning here
|
|
949
|
+
// would leave the runner unable to serve renders (silent 404s).
|
|
950
|
+
files = [];
|
|
951
951
|
}
|
|
952
952
|
|
|
953
953
|
for (const file of files) {
|
|
@@ -989,7 +989,23 @@ async function main() {
|
|
|
989
989
|
}));
|
|
990
990
|
send({ type: "ready", functions });
|
|
991
991
|
|
|
992
|
+
// Belt-and-suspenders against orphaning: if the host dies in a way that
|
|
993
|
+
// somehow leaves our stdin open, we'll have been reparented to init
|
|
994
|
+
// (ppid === 1). Notice and exit. Unref'd so it never keeps us alive on its
|
|
995
|
+
// own.
|
|
996
|
+
const orphanWatch = setInterval(() => {
|
|
997
|
+
if (process.ppid === 1) process.exit(0);
|
|
998
|
+
}, 2000);
|
|
999
|
+
if (typeof orphanWatch.unref === "function") orphanWatch.unref();
|
|
1000
|
+
|
|
992
1001
|
await readerLoop();
|
|
1002
|
+
|
|
1003
|
+
// readerLoop only returns when stdin hits EOF — i.e. the host (the pylon
|
|
1004
|
+
// process that spawned us) is gone. Force-exit. We must NOT rely on the
|
|
1005
|
+
// event loop draining on its own: the stdout writer, keep-alive sockets
|
|
1006
|
+
// from `fetch`, and Bun's own handles keep the process alive, so every
|
|
1007
|
+
// killed `pylon dev` would otherwise orphan its whole bun runner pool.
|
|
1008
|
+
process.exit(0);
|
|
993
1009
|
}
|
|
994
1010
|
|
|
995
1011
|
main().catch((err) => {
|