Add a new QuickJS JSEngine - #446
Open
ryuwd wants to merge 7 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #446 +/- ##
==========================================
+ Coverage 38.78% 39.13% +0.34%
==========================================
Files 50 51 +1
Lines 34620 34813 +193
Branches 8803 8813 +10
==========================================
+ Hits 13428 13623 +195
+ Misses 18308 18306 -2
Partials 2884 2884 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
mr-c
reviewed
Aug 14, 2026
Comment on lines
+757
to
+772
| def _default_js_engine() -> JSEngine: | ||
| """Instantiate the JS engine named by the CWL_JS_ENGINE environment variable.""" | ||
| choice = os.environ.get("CWL_JS_ENGINE", "node") | ||
| if choice == "node": | ||
| return NodeJSEngine() | ||
| if choice == "quickjs": | ||
| qjs_path = shutil.which("qjs") | ||
| if qjs_path is None: | ||
| raise JavascriptException( | ||
| "CWL_JS_ENGINE is set to 'quickjs', but the qjs executable " | ||
| "was not found on PATH." | ||
| ) | ||
| return QuickJSEngine(qjs_path) | ||
| raise ValueError( | ||
| f"Unsupported CWL_JS_ENGINE value {choice!r}: expected 'node' or 'quickjs'." | ||
| ) |
Member
There was a problem hiding this comment.
If QuickJS is faster, why not default to it if the executable is found and CWL_JS_ENGINE is unset?
Author
There was a problem hiding this comment.
Sounds great! Is it worth running the CWL conformance tests first?
mr-c
reviewed
Aug 16, 2026
ryuwd
added a commit
to ryuwd/cwl-utils
that referenced
this pull request
Aug 28, 2026
QuickJS distributions do not share a version scheme (the original QuickJS uses dates while quickjs-ng uses semantic versions), so the check probes the interpreter with a small script exercising the features the engine relies on instead of parsing version strings. A missing or broken interpreter fails the probe rather than raising. Requested in review of common-workflow-language#446.
ryuwd
added a commit
to ryuwd/cwl-utils
that referenced
this pull request
Aug 28, 2026
As suggested in review of common-workflow-language#446. When CWL_JS_ENGINE is unset, the default engine is now QuickJS if a qjs executable is found on the PATH and passes check_js_threshold_version, NodeJS otherwise. Setting CWL_JS_ENGINE to 'node' or 'quickjs' still forces a specific engine, and set_js_engine() still takes precedence. The tests that specifically exercise the NodeJS engine and its software container fallback (which deliberately hide node from the PATH) now pin NodeJSEngine explicitly so they keep testing that code path on systems where qjs is installed, such as CI.
Parameter-reference walking is pure Python and engine independent, so implementations of the JSEngine interface should not each need to provide identical copies. The body is moved verbatim from NodeJSEngine; the return annotation now matches the interface's existing declaration.
QuickJSEngine evaluates CWL expressions with the qjs interpreter.
QuickJS starts in about a millisecond, so each evaluation (and each
exec_js_process call, as used by cwltool's JS expression validation)
runs in one short-lived subprocess with no persistent process or wire
protocol.
get_js_engine() now creates the process-wide engine lazily, honouring
the CWL_JS_ENGINE environment variable ('node', the default, or
'quickjs'); engines installed with set_js_engine() take precedence.
Fixes the three D213 violations flagged by the pydocstyle CI job.
QuickJS distributions do not share a version scheme (the original QuickJS uses dates while quickjs-ng uses semantic versions), so the check probes the interpreter with a small script exercising the features the engine relies on instead of parsing version strings. A missing or broken interpreter fails the probe rather than raising. Requested in review of common-workflow-language#446.
As suggested in review of common-workflow-language#446. When CWL_JS_ENGINE is unset, the default engine is now QuickJS if a qjs executable is found on the PATH and passes check_js_threshold_version, NodeJS otherwise. Setting CWL_JS_ENGINE to 'node' or 'quickjs' still forces a specific engine, and set_js_engine() still takes precedence. The tests that specifically exercise the NodeJS engine and its software container fallback (which deliberately hide node from the PATH) now pin NodeJSEngine explicitly so they keep testing that code path on systems where qjs is installed, such as CI.
ryuwd
marked this pull request as ready for review
September 1, 2026 13:36
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.
This PR adds bellard's
quickjsengine as a supported CWL JS engine, a lighter dependency alternative to node. This PR also makes a JS engine configurable via environment variable e.g.CWL_JS_ENGINE="quickjs".Some refactoring was needed: I've moved
regex_evalintoJSEngineto have the logic shared between the node and quickjs engines - AFAIU it doesn't really depend on a JS engine itself(?)