[Bug] Crash after start if bun
I launch nanocoder, it asks for access to the current directory and immediately crashes into the console.
Hi @pomazanbohdan - thanks for reporting this. Are you able to report which OS and terminal application you're using? I can then get this explored.
Additionally, you're saying you get this if you install via Bun?
Thanks :)
Win 11 25, wsl, oracle linux 9, proto install bun, bun i -g *nanocoder
Root Cause Analysis
Summary
The crash is caused by Pino's transport API incompatibility with the Bun runtime. The application calls pino.transport() early in the startup sequence, before any UI renders or error handling can catch the failure.
Crash Flow
1. User runs: bun nanocoder
2. cli.tsx renders <App />
3. App.tsx:43 - Logger created in useMemo()
└── const logger = useMemo(() => createPinoLogger(), []);
4. pino-logger.ts:82-84 - pino.transport({ target: 'pino/file', ... })
5. ❌ Bun throws: "unable to determine transport target for 'pino/file'"
6. Unhandled exception, app crashes before UI renders
Technical Cause
Pino transports use Node.js worker threads internally. Bun's worker thread implementation differs, causing pino.transport() to fail when dynamically resolving the 'pino/file' target at runtime.
Known Bun/Pino incompatibility issues:
Related Issue: #241
This issue is related to #241 (LoggerProvider async loading bug). The codebase has a LoggerProvider class with a fallback console logger that could prevent this crash, but:
App.tsxbypasses it - callscreatePinoLogger()directly with no fallback- LoggerProvider itself is broken - #241 documents a flag logic bug where
_dependenciesLoadedis set before async loading begins, causing real dependencies to never load
Proposed Fix (Single PR for both issues)
A single PR could close both #128 and #241 by:
-
Fix LoggerProvider's flag logic (#241):
- Use separate flags:
_fallbackInitializedand_realDependenciesLoaded - Allow async Pino loading to complete properly
- Use separate flags:
-
Use LoggerProvider in App.tsx (#128):
- Replace direct
createPinoLogger()call withLoggerProvider.getInstance().getLogger() - Provides graceful fallback when Pino transport fails
- Replace direct
-
Add Bun runtime detection (optional enhancement):
const isBun = typeof globalThis.Bun !== 'undefined'; if (isBun) { // Skip pino.transport(), use console fallback }
Expected Result After Fix
| Runtime | Current Behavior | After Fix |
|---|---|---|
| Node.js | ✅ Works | ✅ Works (Pino file logging) |
| Bun | ❌ Crashes | ✅ Works (console fallback) |
Workaround (for now)
Install with Node.js instead of Bun:
npm i -g nanocoder
Files Involved
source/app/App.tsx:43- Logger initializationsource/utils/logging/pino-logger.ts:74-84- Transport creation (crash site)source/utils/logging/logger-provider.ts- Fallback mechanism (broken, see #241)
Confirmation
Tested locally with Bun v1.3.4 on Linux. The root cause is confirmed:
Node.js:
Testing pino.transport() with Bun...
✅ Transport created successfully
✅ Logger works
Bun:
Testing pino.transport() with Bun...
✅ Transport created successfully
✅ Logger works
❌ Cannot find package 'real-require' from '[email protected]/lib/worker.js'
❌ the worker thread exited
Pino's thread-stream dependency uses worker threads and real-require, which Bun doesn't support properly. The transport appears to initialize but crashes when the worker thread tries to start.
This confirms the fix should add a fallback logger path when pino.transport() fails, which ties into #241.