evlog version
2.14.0
Runtime & OS
bun 1.3.13
Framework / integration
TanStack Start
Adapter or drain (optional)
posthog
Description
When using evlog/nitro/v3 in a TanStack Start / Nitro v3 app deployed to Vercel with Bun runtime, requests fail at runtime with:
error: bun is unable to write files: ReadOnlyFileSystem
Bun process exited with exit status: 1
This appears to be caused by Evlog runtime config discovery probing optional nitropack modules with dynamic imports. Under Bun on Vercel, the missing optional dynamic import can trigger Bun package-manager/cache behavior, which attempts to create/write node_modules/.cache in Vercel’s read-only function filesystem.
Tried with bunfig.toml config
[install]
auto = "disable"
but didn't work.
Expected behavior
In a Nitro v3 app, Evlog should not trigger runtime package resolution for missing optional Nitro 2 / nitropack modules.
If config was already passed to evlog(evlogConfig) in nitro.config.ts, the runtime plugin and adapters should be able to use that config without probing missing optional packages.
Actual behavior
At Vercel runtime, every request failed with:
error: bun is unable to write files: ReadOnlyFileSystem
Bun process exited with exit status: 1
This happened before app-level logs were produced.
As said before, adding a repo-level bunfig.toml did not fix it:
[install]
auto = "disable"
I was able to avoid the runtime failure by (actually it was codex that found the solution :D ):
- Setting process.env.__EVLOG_CONFIG before Evlog’s Nitro plugin initializes.
- Avoiding createPostHogDrain() because it calls the runtime config bridge even when apiKey and host are passed directly.
- Calling sendBatchToPostHog() directly from a custom drain pipeline.
Example workaround:
// server/plugins/evlog-runtime-config.ts
import { definePlugin } from 'nitro';
const evlogConfig = {
env: {
service: 'web',
environment:
process.env.VERCEL_ENV === 'preview'
? 'preview'
: process.env.NODE_ENV === 'production'
? 'production'
: 'development',
},
};
export default definePlugin(() => {
process.env.__EVLOG_CONFIG ??= JSON.stringify(evlogConfig);
});
Reproduction
-
Create a TanStack Start app using Nitro v3 and Bun.
-
Install Evlog:
- Add Evlog’s Nitro v3 module:
// nitro.config.ts
import { defineConfig } from 'nitro';
import evlog from 'evlog/nitro/v3';
const evlogConfig = {
env: {
service: 'repro-app',
environment: 'preview',
},
};
export default defineConfig({
experimental: {
asyncContext: true,
},
modules: [evlog(evlogConfig)],
});
- Add a PostHog drain using explicit config:
// server/plugins/evlog-drain.ts
import { definePlugin } from 'nitro';
import { createPostHogDrain } from 'evlog/posthog';
export default definePlugin((nitroApp) => {
nitroApp.hooks.hook(
'evlog:drain',
createPostHogDrain({
apiKey: process.env.POSTHOG_API_KEY!,
host: '...',
}),
);
});
- Register the plugin:
// nitro.config.ts
export default defineConfig({
experimental: {
asyncContext: true,
},
plugins: ['./server/plugins/evlog-drain'],
modules: [evlog(evlogConfig)],
});
- Configure Vercel to use Bun runtime:
// vercel.json
{
"bunVersion": "1.x"
}
- Deploy to a Vercel preview environment with POSTHOG_API_KEY set.
- Open the deployed preview URL.
Expected result: the app renders normally and Evlog drains logs to PostHog.
Actual result: the Vercel function fails at runtime with:
error: bun is unable to write files: ReadOnlyFileSystem
Bun process exited with exit status: 1
Adding this did not resolve the runtime error:
# bunfig.toml
[install]
auto = "disable"
Logs or structured output (optional)
evlog version
2.14.0
Runtime & OS
bun 1.3.13
Framework / integration
TanStack Start
Adapter or drain (optional)
posthog
Description
When using
evlog/nitro/v3in a TanStack Start / Nitro v3 app deployed to Vercel with Bun runtime, requests fail at runtime with:This appears to be caused by Evlog runtime config discovery probing optional nitropack modules with dynamic imports. Under Bun on Vercel, the missing optional dynamic import can trigger Bun package-manager/cache behavior, which attempts to create/write node_modules/.cache in Vercel’s read-only function filesystem.
Tried with bunfig.toml config
but didn't work.
Expected behavior
In a Nitro v3 app, Evlog should not trigger runtime package resolution for missing optional Nitro 2 / nitropack modules.
If config was already passed to evlog(evlogConfig) in nitro.config.ts, the runtime plugin and adapters should be able to use that config without probing missing optional packages.
Actual behavior
At Vercel runtime, every request failed with:
error: bun is unable to write files: ReadOnlyFileSystem
Bun process exited with exit status: 1
This happened before app-level logs were produced.
As said before, adding a repo-level bunfig.toml did not fix it:
I was able to avoid the runtime failure by (actually it was codex that found the solution :D ):
Example workaround:
Reproduction
Create a TanStack Start app using Nitro v3 and Bun.
Install Evlog:
Expected result: the app renders normally and Evlog drains logs to PostHog.
Actual result: the Vercel function fails at runtime with:
error: bun is unable to write files: ReadOnlyFileSystem
Bun process exited with exit status: 1
Adding this did not resolve the runtime error:
Logs or structured output (optional)