Skip to content

fix(build): escape literal braces in bun:sqlite stub regex (Perl strict)#2111

Open
nuga0718 wants to merge 1 commit into
garrytan:mainfrom
nuga0718:fix/escape-braces-bun-sqlite-regex
Open

fix(build): escape literal braces in bun:sqlite stub regex (Perl strict)#2111
nuga0718 wants to merge 1 commit into
garrytan:mainfrom
nuga0718:fix/escape-braces-bun-sqlite-regex

Conversation

@nuga0718

Copy link
Copy Markdown

Problem

./setup fails on Windows with exit code 255 during the final build step:

Unescaped left brace in regex is illegal here in regex;
marked by <-- HERE in m/import { <-- HERE  Database } from "bun:sqlite";/
error: script "build" exited with code 255

browse/scripts/build-node-server.sh post-processes the Node server bundle with a Perl substitution that stubs out the bun:sqlite import. The pattern contains an unescaped literal {:

perl -pi -e 's|import { Database } from "bun:sqlite";|const Database = null; ...|g' ...

Perl treats an unescaped { that is not part of a valid quantifier as an error, so the build hard-fails before the stub is applied.

Environment

  • Reproduced on Windows Git Bash (msys Perl 5.26.2).
  • Also affects modern Perl 5.32+ on Linux, where the long-standing deprecation became a hard error.

Fix

Escape the braces (\{ \}) so they match literally. One-line change, behavior-preserving.

Verification

After the fix, on the same Windows environment:

  • Build completes with exit code 0.
  • The substitution correctly produces const Database = null; // bun:sqlite stubbed on Node (no real from "bun:sqlite" import remains).
  • The Windows compatibility polyfill header is injected.
  • node --check browse/dist/server-node.mjs passes.

🤖 Generated with Claude Code

The Node server bundle post-processing in build-node-server.sh uses a
Perl substitution with an unescaped literal `{` in the pattern
`import { Database } from "bun:sqlite";`. Perl treats an unescaped `{`
that is not part of a valid quantifier as an error ("Unescaped left
brace in regex is illegal here in regex"), hard-failing the build with
exit code 255 and breaking `./setup`.

Reproduced on Windows Git Bash (msys Perl 5.26.2); also affects modern
Perl 5.32+ on Linux. Escaping the braces (`\{ \}`) matches them
literally and is backward compatible; verified the substitution still
produces the expected `const Database = null` stub and `node --check`
passes on the resulting server-node.mjs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@trunk-io

trunk-io Bot commented Jun 25, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

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.

2 participants