Commit 376e2a4
fix(sea): set process.pkg in worker threads (#270)
Classic (non-SEA) pkg sets process.pkg on every thread because
bootstrap.js runs end-to-end in both main and worker threads. In SEA
mode the worker entry only mounted the VFS and skipped setupProcessPkg,
so userland helpers that gate on 'pkg' in process (a common pattern for
picking process.cwd() vs __dirname when resolving runtime paths) saw
undefined inside workers and routed writes into the read-only snapshot.
A concrete symptom: a pino transport running in a worker thread whose
target resolves a log directory through such a check would try to open
a file under /snapshot/... and hang forever on the 'open' event; the
main thread then surfaced the misleading "the worker has exited" error
from thread-stream.writes with no real cause.
Mirror the main-thread call in sea-worker-entry.js so process.pkg
is populated consistently across threads, and extend the existing
worker-threads SEA test to assert process.pkg.entrypoint is set inside
the worker so this can't silently regress.
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>1 parent c0233e6 commit 376e2a4
4 files changed
Lines changed: 27 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
9 | 19 | | |
10 | 20 | | |
11 | 21 | | |
| |||
19 | 29 | | |
20 | 30 | | |
21 | 31 | | |
| 32 | + | |
22 | 33 | | |
23 | 34 | | |
0 commit comments