Node + tsx '__name is not a function' Crash Resolution
This page documents a historical crash when running OpenClaw development scripts with tsx on Node 25, caused by esbuild's keepNames option. It covers the symptom, cause, and resolution for developers maintaining the project.
Read this when
- Investigating a tsx/esbuild loader crash that mentions a missing __name helper
Node + tsx "__name is not a function" crash
Status
This issue has been resolved. The crash no longer occurs with the current tsx version locked in package.json (4.22.3) or with recent Node releases. The documentation remains here in case a future tsx or esbuild update brings the problem back.
Original symptom
When executing OpenClaw development scripts through tsx, the process failed during startup with the following error:
[openclaw] Failed to start CLI: TypeError: __name is not a function
at createSubsystemLogger (src/logging/subsystem.ts)
at <caller> (src/agents/auth-profiles/constants.ts)
Line numbers have been excluded because both files have changed since the original crash occurred, and the specific lines no longer correspond.
This error surfaced after development scripts moved from Bun to tsx (2871657e, 2026-01-06) to make Bun optional. The equivalent workflow using Bun did not crash. The issue was first seen on Node v25.3.0 running macOS; other platforms using Node 25 were also expected to be affected.
Cause
tsx converts TS and ESM code through esbuild with keepNames: true set directly in its transform configuration. This option causes esbuild to wrap named function and class declarations inside a call to a __name helper, so fn.name remains intact after minification and bundling. The crash indicates that the helper was either missing or overshadowed at the call location for that module in the specific tsx and Node combination, causing __name(...) to throw an error rather than return the wrapped value.
Current repro check
node --version
pnpm install
node --import tsx src/entry.ts status
A minimal isolated reproduction (loading only the module from the original stack trace):
node --import tsx scripts/repro/tsx-name-repro.ts
Both commands currently complete without errors. If either raises __name is not a function again, record the exact Node version, the tsx version (node_modules/tsx/package.json), and the full stack trace before reporting the issue upstream.
Workarounds (if the crash returns)
-
Use Bun instead of
node --import tsxto run development scripts. -
Execute
pnpm tsgofor type checking, then run the compiled output rather than the source throughtsx:pnpm tsgo node openclaw.mjs status -
Try a different
tsxversion (changingpnpm add -D tsx@<version>is a dependency update that requires approval per repository policy) to determine whether the esbuild version it bundles reintroduced the bug. -
Test on a different Node major or minor release to check whether the failure depends on the version.