Conversation
…export can run Python
|
@alegal200 is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
🤖 auto-maintain reviewAutomated, advisory triage for
Review panel: 🟡 medium highest severity just-bash maintainer code review: 🟢 low
General code review: 🟡 medium
Adversarial security: 🟢 low
Adversarial security (second opinion): 🟢 low
Standard Bash and host portability: 🟢 low
Posted by auto-maintain. This automated code review is advisory; a human maintainer makes the call. |
…the python timeout
Problem
python3fails on every invocation when the library is loaded through its CommonJS export. Node 24.10.0, darwin arm64, pristinejust-bash@3.4.2from npm:The ESM export of the same version succeeds. Everything else in the CJS bundle works —
echo ok; python3 -c "print(1+1)"printsokand then fails only on the interpreter — so this reads as a Python problem rather than a packaging one. Reproduced on 3.2.0, 3.3.0 and 3.4.2.Cause
The worker was located with
new URL("./worker.js", import.meta.url).build:lib:cjsruns esbuild with--format=cjs, which replacesimport.metawith an empty object, so the base URL isundefinedand the constructor throwsERR_INVALID_URL. The minified bundle shows it directly:Bde = {}andCde = fileURLToPath(new URL("./worker.js", Bde.url)).Same root cause as #385, which reports it for
js-exec. That half appears to be addressed onmainby #394 —js-execnow delegates torunand loads no worker file of its own — whilepython3still resolves its worker this way.Fix
The module directory is read from
__dirnamewhen running as CommonJS and fromimport.meta.urlotherwise, then the worker is looked up in the two layouts it ships in:<dir>/worker.js— source tree, ESM bundle and CLI chunks dirs, non-bundled dist<dir>/chunks/worker.js— the CJS bundle, where the library is a singledist/bundle/index.cjsand the worker sits one level downThis mirrors
sqlite3's existingfindWorkerPath(), including the_internalsexport for tests. A missing worker now names the worker and the build step instead of surfacing as an invalid URL. The failure surface is unchanged otherwise: both before and after, a failure arrives as apython3:command error rather than a crash at load.Tests
python3.worker-resolution.test.ts— resolution order against synthetic directories, modelled onsqlite3.worker-resolution.test.ts.bundle-cjs.test.ts—require()s the built bundle in a child process and runspython3 -c "print(1 + 1)", added totest:dist. The CJS entry point had no runtime coverage: the suite runs against the source tree, andexamples/cjs-consumeronly typechecks and only runsecho. That is why this shipped in three releases.Verified locally: the new CJS test fails with
python3: Invalid URLagainst a build without the fix, and passes with it.test:dist19/19,test:wasm715 passed / 2 skipped,typecheck,lintandknipclean. The 7 failures intest:runon my machine (tarxz, symlinked root, hard links) reproduce identically on unmodifiedmain.One judgement call for you
Locating the worker needs
existsSync, andnode:fsis a banned import incommands/python3/python3.ts. I used the documented@banned-pattern-ignoreopt-out with the worker-bootstrap-gate reason. If you would rather keep the policy symmetric, the alternative is addingpython3/python3next tosqlite3/sqlite3in the rule'sfilePatterninscripts/check-banned-patterns.js— happy to switch.Refs #385