Skip to content

Fix Dynamic require of "tty" crash under ESM Node (#211)#238

Merged
cramforce merged 1 commit into
mainfrom
fix-211
May 13, 2026
Merged

Fix Dynamic require of "tty" crash under ESM Node (#211)#238
cramforce merged 1 commit into
mainfrom
fix-211

Conversation

@cramforce
Copy link
Copy Markdown
Contributor

The esbuild dynamic-require shim in the ESM Node bundles had no real require to delegate to at chunk-init, so any runtime require("tty") / require("os") from the file-typedebugsupports-color chain threw "Dynamic require of "tty" is not supported". This made the file command crash for every consumer importing just-bash as ESM and for the just-bash CLI binary.

Provide createRequire(import.meta.url) via the build banner for build:lib, build:cli, and build:shell. CJS and browser bundles are unchanged.

Add regression tests covering both the bundled CLI binary and the ESM library bundle running the file command.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
just-bash-website Ready Ready Preview, Comment May 13, 2026 5:54pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
just-bash Ignored Ignored May 13, 2026 5:54pm

The esbuild dynamic-require shim in the ESM Node bundles had no real
`require` to delegate to at chunk-init, so any runtime `require("tty")`
/ `require("os")` from the `file-type` → `debug` → `supports-color`
chain threw "Dynamic require of \"tty\" is not supported". This made
the `file` command crash for every consumer importing just-bash as ESM
and for the `just-bash` CLI binary.

Provide `createRequire(import.meta.url)` via the build banner for
`build:lib`, `build:cli`, and `build:shell`. CJS and browser bundles
are unchanged.

Add regression tests covering both the bundled CLI binary and the ESM
library bundle running the `file` command.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 13, 2026

Deployment failed with the following error:

The Preview Deployment Suffix domain "labs.vercel.dev" is not available under the current scope. Learn more: https://vercel.link/3a1

@cramforce cramforce merged commit 01a4721 into main May 13, 2026
10 of 13 checks passed
@github-actions github-actions Bot mentioned this pull request May 13, 2026
ezzabuzaid pushed a commit to JanuaryLabs/deepagents that referenced this pull request May 24, 2026
…ption

createSqlCommand now exposes only `sql run` and `sql validate` as just-bash
customCommands. Bootstrap (schema indexing) belongs on the host — callers
should invoke `text2Sql.index()` directly before sandbox construction.
instructions() only teaches the LLM `sql run` / `sql validate` anyway.

Replaces the local SqlCommandError class with one that extends BashException
per the codebase convention (see sql-transform-plugins.ts:54). The class
carries the subcommand name and exitCode; format() returns a properly-
prefixed `sql <subcommand>: <msg>\n` CommandResult. runHandler catches
BashException locally and calls format() because just-bash's Bash.exec
intercepts throws from customCommand handlers and rewrites them to a
generic exit-1 string — BashException.format() is only honored when the
throw reaches withBashExceptionCatch at the sandbox decorator layer, which
requires catching inside the handler first.

Also bumps just-bash ^3.0.0 -> ^3.0.1 across the workspace. 3.0.1 patches
a `Dynamic require of "tty"` crash in the file-type -> debug ESM chain
(vercel-labs/just-bash#238); catch site for customCommand throws is
unchanged across versions.
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