Skip to content

Commit 1975b17

Browse files
committed
fix: disable pino-pretty in compiled Bun binaries
Adds isCompiledBinary() detection to identify when running in a compiled Bun binary by checking if import.meta.url starts with file:///$bunfs/. ### Fixes - Disable pino-pretty transport in compiled binaries to prevent runtime resolution errors since pino-pretty cannot be resolved from the virtual /$bunfs/ filesystem - Add JSDoc comments explaining compiled binary detection logic ### Technical Details - Compiled Bun binaries use a virtual /$bunfs/ filesystem where external modules like pino-pretty are not accessible at runtime - isPrettyMode() now returns false for compiled binaries regardless of DEBUG or NODE_ENV settings
1 parent d0c6ed5 commit 1975b17

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/lib/logger.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
import pino from "pino";
22

3+
/**
4+
* Detect if running in a compiled Bun binary.
5+
* Compiled binaries run from /$bunfs/ virtual filesystem.
6+
*/
7+
function isCompiledBinary(): boolean {
8+
return import.meta.url.startsWith("file:///$bunfs/");
9+
}
10+
311
/**
412
* Determine if we should use pretty printing.
513
* Pretty print when DEBUG is set or NODE_ENV=development.
14+
* Never use pretty printing in compiled binaries (pino-pretty can't be resolved).
615
*/
716
function isPrettyMode(): boolean {
17+
if (isCompiledBinary()) {
18+
return false;
19+
}
820
return Boolean(process.env.DEBUG) || process.env.NODE_ENV === "development";
921
}
1022

0 commit comments

Comments
 (0)