Fix migration 0008 parser stack overflow on macOS bun:sqlite#745
Merged
RhysSullivan merged 2 commits intomainfrom May 10, 2026
Merged
Fix migration 0008 parser stack overflow on macOS bun:sqlite#745RhysSullivan merged 2 commits intomainfrom
RhysSullivan merged 2 commits intomainfrom
Conversation
Migration 0008 inlined a 41-deep nested replace() chain (8 dash-collapse replaces wrapping lower(33 single-char replaces wrapping the raw input)) to slugify header names into slot_keys. Bun's lemon SQL parser stack overflows at PREPARE time on the compiled CLI binary on macOS, so users upgrading on Mac couldn't start the CLI at all (the Linux test matrix in CI never exercised the failing path). Replace the deep chain with a temp __slug_norm table populated once at the top of the migration via a series of shallow UPDATE statements (one per replacement), then reference the precomputed slug via flat scalar subqueries everywhere. Semantics verified equivalent against 25 inputs covering case, punctuation, whitespace, dashes-only and unicode. Add structural lint that scans every drizzle migration file and rejects any nested-function call > 20 deep. Catches the regression class on Linux CI without needing macOS in the matrix.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
executor-marketing | 398028e | Commit Preview URL Branch Preview URL |
May 10 2026, 06:33 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
executor-cloud | 398028e | May 10 2026, 06:33 AM |
- Remove .changeset/fix-migration-0008-parser-overflow.md: the existing
.changeset/executor-1.4.16.md (still in main, consumed when the open
Version Packages PR merges) is enough to ship 1.4.16 with this fix
included.
- Replace throw new Error(...) in migration-nesting.test.ts with a
shaped expect(...).toEqual({...}) that prints file/line/fn/depth in
the diff. Satisfies oxlint's no-error-constructor / no-try-catch-or-throw
rules without losing the diagnostic.
@executor-js/cli
@executor-js/config
@executor-js/execution
@executor-js/sdk
@executor-js/storage-core
@executor-js/codemode-core
@executor-js/runtime-quickjs
@executor-js/plugin-file-secrets
@executor-js/plugin-google-discovery
@executor-js/plugin-graphql
@executor-js/plugin-keychain
@executor-js/plugin-mcp
@executor-js/plugin-onepassword
@executor-js/plugin-openapi
executor
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migration
0008_scoped_credentials_cutover.sqlinlined a 41-deep nestedreplace()chain to slugify header / scheme / param names intoslot_keystrings. bun:sqlite's lemon parser stack overflows at PREPARE time on the compiled CLI binary on macOS, so users upgrading on Mac couldn't start the CLI at all — the migration aborts withSQLiteError: parser stack overflow. Linux CI never exercised the path.Refactor the migration to precompute slugs once into a
__slug_normtemp table at the top, via a series of shallowUPDATEstatements (one per replacement), then reference the result via flat scalar subqueries (COALESCE((SELECT slug FROM __slug_norm WHERE raw = X), 'default')) at all 34 use sites.Also add a structural lint test that scans every drizzle migration file and rejects any nested-function call deeper than 20 levels. Catches the regression class on Linux CI without needing macOS in the matrix.
Why
The user-facing failure on macOS:
Bun ships SQLite compiled with a small
YYSTACKDEPTH. The 41-deep chain (8 dash-collapsereplace()wrappinglower()wrapping 33 single-charreplace()wrappingtrim()wrapping the raw input) reaches the limit on the compiled binary's smaller thread stack on macOS. Note that running tests withbunx --bun viteston Linux also passes — only the compiled binary on macOS trips it.What changed
apps/local/drizzle/0008_scoped_credentials_cutover.sql— added__slug_normtemp table setup at the top (oneUPDATEper character replacement; 41 shallow statements total). Replaced 34 occurrences of the deep chain withCOALESCE((SELECT \slug` FROM `__slug_norm` WHERE `raw` = ...), 'default').DROP TABLE __slug_norm` at the end. Net: +120/-34 lines.apps/local/src/server/migration-nesting.test.ts— new structural lint test. Walks every migration.sqltracking nested same-name function calls; fails if any single function nests > 20 deep. One test per migration file (11 tests). Verified to fail on the original 0008 and pass on the refactored one..changeset/fix-migration-0008-parser-overflow.md—"executor": patchso this lands in 1.4.16 before publish (PR 743 is still open; this fix piggybacks on the same Version Packages PR).Test plan
bunx --bun vitest runinapps/local— 51 tests pass (including 40 migration tests across the 0007–0010 path)~/.executor/data.dbthat's at migration 0006 (the failing scenario)Follow-up (not in this PR)
Add macOS to the test matrix in
pkg-pr-new.ymlandci.yml. The structural lint catches THIS shape of bug, but the test matrix gap is real — anything else that's macOS-specific would also slip through.