fix(paths): skip pino-pretty transport in compiled binaries#962
fix(paths): skip pino-pretty transport in compiled binaries#962
Conversation
The Pino logger unconditionally configured `transport: { target: 'pino-pretty' }`
whenever stdout is a TTY. Pino transports spawn a worker that performs a dynamic
`require.resolve('pino-pretty')` at runtime, which cannot resolve inside Bun's
`/$bunfs/` virtual filesystem in `bun build --compile` binaries. As a result,
every CLI command crashed on startup in a real terminal:
error: unable to determine transport target for "pino-pretty"
at I (/$bunfs/root/archon-linux-x64:7:35652)
100% of fresh binary installs were unusable. Piping output (e.g. `archon
version | cat`) masked the bug because `isTTY` became false.
Compiled binaries now always emit NDJSON. Detection is inlined here because
`@archon/paths` has zero `@archon/*` dependencies; it checks both
`import.meta.dir` (covers ESM compiled binaries) and `process.execPath`
basename (covers CJS bytecode binaries where `import.meta.dir` is empty).
Fixes #960
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…stream logger
Replaces runtime detection of compiled binaries (env sniffing via
import.meta.dir / process.execPath) with a build-time BUNDLED_IS_BINARY
constant in @archon/paths/bundled-build.ts, rewritten by
scripts/build-binaries.sh and restored on EXIT via a trap.
Also rewrites @archon/paths/logger.ts to use pino-pretty as a destination
stream instead of a worker-thread transport. The formatter now runs on
the main thread, eliminating the require.resolve('pino-pretty') lookup
that crashes inside Bun's /\$bunfs/ virtual filesystem in compiled
binaries. The same code path runs in dev and binaries — no environment
detection in the logger at all.
isBinaryBuild() in @archon/workflows is kept as a one-line wrapper
around BUNDLED_IS_BINARY so existing spyOn-based test mocking in
loader.test.ts continues to work without modification.
Closes #960
Closes #961
Closes #979
Supersedes #962
Supersedes #963
Co-Authored-By: leex279 <leex279@users.noreply.github.com>
…stream logger (#982) * fix(build): use build-time constants for binary detection and pretty stream logger Replaces runtime detection of compiled binaries (env sniffing via import.meta.dir / process.execPath) with a build-time BUNDLED_IS_BINARY constant in @archon/paths/bundled-build.ts, rewritten by scripts/build-binaries.sh and restored on EXIT via a trap. Also rewrites @archon/paths/logger.ts to use pino-pretty as a destination stream instead of a worker-thread transport. The formatter now runs on the main thread, eliminating the require.resolve('pino-pretty') lookup that crashes inside Bun's /\$bunfs/ virtual filesystem in compiled binaries. The same code path runs in dev and binaries — no environment detection in the logger at all. isBinaryBuild() in @archon/workflows is kept as a one-line wrapper around BUNDLED_IS_BINARY so existing spyOn-based test mocking in loader.test.ts continues to work without modification. Closes #960 Closes #961 Closes #979 Supersedes #962 Supersedes #963 Co-Authored-By: leex279 <leex279@users.noreply.github.com> * style(workflows): hoist BUNDLED_IS_BINARY import to top of file * fix(build,logger): harden pretty init and trap restore - logger: wrap pino-pretty init in try/catch and fall back to JSON so a broken TTY or missing peer can't crash module load. - build-binaries.sh: drop '2>/dev/null || true' from the EXIT trap so a failed bundled-build.ts restore is visible instead of silently leaving the dev tree with BUNDLED_IS_BINARY=true. - bundled-defaults: unmark isBinaryBuild() @deprecated and document why the wrapper is the intentional test seam (mock.module pollution in Bun). --------- Co-authored-by: leex279 <leex279@users.noreply.github.com>
|
Closing — superseded by #982 which replaces both this PR and #963 with a build-time constants refactor ( Why the architectural redirect: the runtime detection approach needed two ANDed heuristics per package ( For the logger specifically: #982 uses Thank you @leex279 for catching the underlying bugs in #960/#961 and providing the initial fixes here. Your diagnosis drove the refactor; the new implementation credits you in its commit message. The |
- Remove duplicate 'returns null when no resumable run exists' test that was accidentally left in alongside the newly-added one - Fix twoDaysAgo timestamp arithmetic (was 48 minutes, not 2 days) - Add test for last_activity_at IS NULL branch in findResumableRun - Change warn → error + add errorType in findResumableRun catch block - Add errorType to workflow.ts signal cleanup catch - Add errorType to cli.ts failOrphanedRuns startup catch - Add inline comment clarifying nowMinusDays(3) uses param index, not day count
…ix-issue-961 fix: prevent SIGTERM from orphaning CLI workflow runs
- Remove duplicate 'returns null when no resumable run exists' test that was accidentally left in alongside the newly-added one - Fix twoDaysAgo timestamp arithmetic (was 48 minutes, not 2 days) - Add test for last_activity_at IS NULL branch in findResumableRun - Change warn → error + add errorType in findResumableRun catch block - Add errorType to workflow.ts signal cleanup catch - Add errorType to cli.ts failOrphanedRuns startup catch - Add inline comment clarifying nowMinusDays(3) uses param index, not day count
…ix-issue-961 fix: prevent SIGTERM from orphaning CLI workflow runs
…stream logger (coleam00#982) * fix(build): use build-time constants for binary detection and pretty stream logger Replaces runtime detection of compiled binaries (env sniffing via import.meta.dir / process.execPath) with a build-time BUNDLED_IS_BINARY constant in @archon/paths/bundled-build.ts, rewritten by scripts/build-binaries.sh and restored on EXIT via a trap. Also rewrites @archon/paths/logger.ts to use pino-pretty as a destination stream instead of a worker-thread transport. The formatter now runs on the main thread, eliminating the require.resolve('pino-pretty') lookup that crashes inside Bun's /\$bunfs/ virtual filesystem in compiled binaries. The same code path runs in dev and binaries — no environment detection in the logger at all. isBinaryBuild() in @archon/workflows is kept as a one-line wrapper around BUNDLED_IS_BINARY so existing spyOn-based test mocking in loader.test.ts continues to work without modification. Closes coleam00#960 Closes coleam00#961 Closes coleam00#979 Supersedes coleam00#962 Supersedes coleam00#963 Co-Authored-By: leex279 <leex279@users.noreply.github.com> * style(workflows): hoist BUNDLED_IS_BINARY import to top of file * fix(build,logger): harden pretty init and trap restore - logger: wrap pino-pretty init in try/catch and fall back to JSON so a broken TTY or missing peer can't crash module load. - build-binaries.sh: drop '2>/dev/null || true' from the EXIT trap so a failed bundled-build.ts restore is visible instead of silently leaving the dev tree with BUNDLED_IS_BINARY=true. - bundled-defaults: unmark isBinaryBuild() @deprecated and document why the wrapper is the intentional test seam (mock.module pollution in Bun). --------- Co-authored-by: leex279 <leex279@users.noreply.github.com>
- Remove duplicate 'returns null when no resumable run exists' test that was accidentally left in alongside the newly-added one - Fix twoDaysAgo timestamp arithmetic (was 48 minutes, not 2 days) - Add test for last_activity_at IS NULL branch in findResumableRun - Change warn → error + add errorType in findResumableRun catch block - Add errorType to workflow.ts signal cleanup catch - Add errorType to cli.ts failOrphanedRuns startup catch - Add inline comment clarifying nowMinusDays(3) uses param index, not day count
…ix-issue-961 fix: prevent SIGTERM from orphaning CLI workflow runs
…stream logger (coleam00#982) * fix(build): use build-time constants for binary detection and pretty stream logger Replaces runtime detection of compiled binaries (env sniffing via import.meta.dir / process.execPath) with a build-time BUNDLED_IS_BINARY constant in @archon/paths/bundled-build.ts, rewritten by scripts/build-binaries.sh and restored on EXIT via a trap. Also rewrites @archon/paths/logger.ts to use pino-pretty as a destination stream instead of a worker-thread transport. The formatter now runs on the main thread, eliminating the require.resolve('pino-pretty') lookup that crashes inside Bun's /\$bunfs/ virtual filesystem in compiled binaries. The same code path runs in dev and binaries — no environment detection in the logger at all. isBinaryBuild() in @archon/workflows is kept as a one-line wrapper around BUNDLED_IS_BINARY so existing spyOn-based test mocking in loader.test.ts continues to work without modification. Closes coleam00#960 Closes coleam00#961 Closes coleam00#979 Supersedes coleam00#962 Supersedes coleam00#963 Co-Authored-By: leex279 <leex279@users.noreply.github.com> * style(workflows): hoist BUNDLED_IS_BINARY import to top of file * fix(build,logger): harden pretty init and trap restore - logger: wrap pino-pretty init in try/catch and fall back to JSON so a broken TTY or missing peer can't crash module load. - build-binaries.sh: drop '2>/dev/null || true' from the EXIT trap so a failed bundled-build.ts restore is visible instead of silently leaving the dev tree with BUNDLED_IS_BINARY=true. - bundled-defaults: unmark isBinaryBuild() @deprecated and document why the wrapper is the intentional test seam (mock.module pollution in Bun). --------- Co-authored-by: leex279 <leex279@users.noreply.github.com>
Summary
bun build --compilebinaries crash on every TTY invocation witherror: unable to determine transport target for "pino-pretty"because Pino transports do a dynamicrequire.resolve('pino-pretty')that cannot work inside Bun's/$bunfs/virtual filesystem.@archon/pathsbecause that package has zero@archon/*dependencies (per CLAUDE.md). It checks bothimport.meta.dir(ESM compiled binaries) andprocess.execPathbasename (CJS bytecode binaries whereimport.meta.dirmay be empty).Fixes #960
Test plan
bun --filter @archon/paths test— 83 pass, 0 failbun build --compile --outfile dist/archon-test.exe packages/cli/src/cli.ts && ./dist/archon-test.exe versionnow printsBuild: binaryinstead of crashing.bun --filter @archon/paths type-check— cleandev