Skip to content

fix(compiler): set DuckDB temp_directory so spills don't depend on a writable cwd - #41

Merged
lukaisailovic merged 1 commit into
mainfrom
fix/duckdb-temp-directory
Jun 26, 2026
Merged

fix(compiler): set DuckDB temp_directory so spills don't depend on a writable cwd#41
lukaisailovic merged 1 commit into
mainfrom
fix/duckdb-temp-directory

Conversation

@lukaisailovic

Copy link
Copy Markdown
Owner

What

In-memory DuckDB defaulted its disk-spill directory to `./.tmp` relative to the process cwd because `temp_directory` was never set. The moment a query spilled to disk and the cwd wasn't writable, it failed with:

```
IO Error: Failed to create directory ".tmp": Permission denied
```

This bit the Docker image: `WORKDIR /app` is root-owned, the runtime runs as `node`, and `serve` validates every app at boot — so a dataset whose query spilled to disk crashed boot validation and the whole workspace refused to serve. Version-independent and latent; it surfaced once agent-edited data grew large enough to spill.

Fix

Added `createInMemoryDuckDB()` in `packages/compiler/src/writers.ts` that passes a writable `temp_directory` under `os.tmpdir()`, and routed all five `DuckDBInstance.create(":memory:")` call sites (engine builder + inspect/infer paths + writers) through it.

Test

`pnpm build && pnpm typecheck && pnpm test && pnpm lint` all pass (392 tests).

…writable cwd

In-memory DuckDB defaulted its disk-spill dir to ./.tmp relative to the
process cwd. When a query spilled and the cwd wasn't writable (Docker
WORKDIR /app is root-owned, runtime runs as node), it failed with
"IO Error: Failed to create directory .tmp". Route every in-memory
instance through createInMemoryDuckDB(), which sets a writable
temp_directory under os.tmpdir().
@lukaisailovic
lukaisailovic merged commit e81ce8b into main Jun 26, 2026
2 checks passed
@lukaisailovic
lukaisailovic deleted the fix/duckdb-temp-directory branch June 26, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant