-
Notifications
You must be signed in to change notification settings - Fork 802
Migrate JavaScript evaluator from Nashorn to GraalJS #631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
25 tasks
c53e16d to
bde59d6
Compare
Fixes #617 ## Summary Replaces deprecated Nashorn JavaScript engine (removed in Java 15) with GraalJS, porting production-tested enterprise features from Orkes Conductor to OSS. ## Enterprise Feature Port This implementation is based on OrkesScriptEvaluator from Orkes Enterprise, adapted for OSS with the following enterprise features: ### Ported Features: - GraalJS engine implementation (battle-tested in production) - Timeout protection (prevents runaway scripts) - Context pooling (optional performance optimization) - ConsoleBridge (console logging support) - Deep copy protection (prevents PolyglotMap issues) - Enhanced error handling (line number information) ### Excluded (Enterprise-only): - Spring @value configuration injection - Enterprise telemetry/monitoring hooks - Enterprise-specific error reporting ### Adapted for OSS: - Environment variable configuration (vs Spring properties) - Self-initializing with defaults (no Spring DI required) - Simplified configuration model ## Changes ### Core Implementation - Migrated ScriptEvaluator from Nashorn to GraalJS with timeout protection - Added ConsoleBridge for console.log/info/error support - Updated JavascriptEvaluator with deep copy protection for PolyglotMap issues - Updated exception handling in DecisionTaskMapper, DoWhile, WorkflowTaskTypeConstraint ### Dependencies - Added GraalJS dependencies (org.graalvm.js:js:24.1.0, js-scriptengine:24.1.0) - Removed Nashorn dependency (org.openjdk.nashorn:nashorn-core) ### Features Added (from Enterprise) - ES6+ JavaScript support (const, let, arrow functions, template literals, etc.) - Script execution timeout protection (4 seconds default, configurable) - Optional context pooling for improved performance - Enhanced error messages with line number information - ConsoleBridge for capturing console output in tasks - Deep copy protection for workflow task data ### Configuration New optional environment variables: - CONDUCTOR_SCRIPT_MAX_EXECUTION_SECONDS (default: 4) - CONDUCTOR_SCRIPT_CONTEXT_POOL_SIZE (default: 10) - CONDUCTOR_SCRIPT_CONTEXT_POOL_ENABLED (default: false) ### Testing - Updated existing ScriptEvaluator tests for GraalJS - Added comprehensive TestGraalJSFeatures test suite (16 tests) - Tests cover enterprise features: timeout, console, context pooling - All tests passing with Java 17 ## Backward Compatibility - 100% backward compatible at application level - All existing workflows continue to work unchanged - No API changes, workflow definitions, or syntax changes - Deprecated: CONDUCTOR_NASHORN_ES6_ENABLED env var (no longer needed) ## Version Impact Minor version bump (3.23.0) - adds enterprise features, fixes deprecated dependency, maintains backward compatibility. Java 17 requirement was already established on main branch in PR #3733. ## Enterprise Parity Brings OSS closer to feature parity with Orkes Enterprise by porting production-tested JavaScript evaluation capabilities. Timeout protection and error handling improvements are particularly valuable for production deployments. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
bde59d6 to
840ec19
Compare
- Added JavascriptEvaluatorTest (8 tests) for deep copy protection - Added GraalJSEvaluatorTest (7 tests) for new evaluator type - Extended TestGraalJSFeatures (+5 tests) for context pooling, initialization, error handling - All Enterprise features now have dedicated test coverage - 45+ total tests covering all changes in this PR
Contributor
Author
|
Adding in a whole bunch of tests. |
manan164
approved these changes
Nov 5, 2025
Contributor
manan164
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please apply spotless.
2bb2bf3 to
02c8b68
Compare
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.
Summary
Replaces deprecated Nashorn JavaScript engine (removed in Java 15) with GraalJS, porting enterprise-grade features from Orkes Conductor Enterprise to OSS. Also adds future-proof evaluator architecture for supporting multiple scripting engines.
Fixes #617
Motivation
Nashorn was deprecated in Java 11 and removed in Java 15 (2020). With Conductor OSS now requiring Java 17+ on main branch, this migration:
This is not just an engine swap - it brings enterprise-grade JavaScript evaluation features to OSS and prepares the platform for multi-language scripting support.
What's Being Ported from Enterprise
This implementation is based on
OrkesScriptEvaluatorfrom Orkes Conductor Enterprise, adapted for OSS:Ported Features:
Excluded (Enterprise-only):
Adapted for OSS:
Changes
Core Implementation
ScriptEvaluatorfrom Nashorn to GraalJS (based on Enterprise version)ConsoleBridgefor console.log/info/error supportGraalJSEvaluatorfor explicit GraalJS evaluator typeJavascriptEvaluatorwith deep copy protection (from Enterprise)evaluatorTypeparameter optional in INLINE tasks (defaults to "javascript")Dependencies
org.graalvm.js:js:24.1.0,org.graalvm.js:js-scriptengine:24.1.0org.openjdk.nashorn:nashorn-core:15.4Features Added
INLINE Task Enhancements - Future-Proof Architecture
The
evaluatorTypeparameter is now optional and extensible:{ "name": "INLINE", "type": "INLINE", "inputParameters": { "evaluatorType": "graaljs", "expression": "$.value * 2" } }Supported evaluator types:
"javascript"- JavaScript via GraalJS (default if omitted)"graaljs"- Explicit GraalJS (same engine, future-proof naming)"python"- Python via GraalVM Python (already supported)"value-param"- Simple parameter evaluation (already supported)Backward compatibility: Existing workflows without
evaluatorTypedefault to"javascript"and work unchanged.Forward compatibility: Architecture supports adding new scripting engines (Ruby, Go, etc.) without breaking changes.
Configuration
New optional environment variables:
Deprecated:
CONDUCTOR_NASHORN_ES6_ENABLED- No longer needed (ES6+ works by default)Testing
TestGraalJSFeaturestest suite (16 tests covering enterprise features)Test Coverage
Backward & Forward Compatibility
✅ Backward Compatibility (100%)
Application Level:
$.variablesyntaxevaluatorTypedefault to"javascript"Examples that continue to work:
Breaking changes:
CONDUCTOR_NASHORN_ES6_ENABLEDenv var✅ Forward Compatibility
Extensible Architecture:
"graaljs") prepare for future language optionsFuture possibilities:
Design benefits:
Version Impact
Recommendation: MINOR version bump (3.23.0)
Per Semantic Versioning 2.0.0:
Rationale:
Why not MAJOR:
Why not PATCH:
Conclusion: This is a feature enhancement that maintains backward compatibility and enables forward compatibility - textbook definition of a MINOR release.
Enterprise Parity Context
This change brings OSS closer to feature parity with Orkes Enterprise:
The timeout protection and error handling improvements are particularly valuable for production deployments. The evaluator architecture prepares Conductor OSS for multi-language scripting support.
Files Changed
Core files:
core/build.gradle- Dependenciescore/.../ScriptEvaluator.java- GraalJS implementation (based on Enterprise)core/.../JavascriptEvaluator.java- Deep copy protection (from Enterprise)core/.../GraalJSEvaluator.java- NEW - Explicit GraalJS evaluatorcore/.../ConsoleBridge.java- NEW - Console logging (from Enterprise)core/.../Inline.java- Optional evaluatorType with defaultcore/.../DecisionTaskMapper.java- Exception handlingcore/.../DoWhile.java- Exception handlingcore/.../WorkflowTaskTypeConstraint.java- Exception handlingTest files:
core/.../TestScriptEval.java- Updated testscore/.../TestGraalJSFeatures.java- NEW - Comprehensive enterprise feature testscore/.../InlineTest.java- Added graaljs and default evaluatorType testsDocumentation:
CHANGELOG.md- Migration notes with enterprise feature calloutsChecklist
Migration Notes for Users
Required:
Optional:
CONDUCTOR_NASHORN_ES6_ENABLEDenv var if set (no longer needed)"graaljs"evaluator type for new workflows (future-proof)Benefits from This Release:
Transparency Note
This PR ports the proven, production-tested GraalJS implementation from Orkes Conductor Enterprise, adapted for OSS. The Enterprise version has been running in production with these features, providing confidence in stability and correctness.
The evaluator architecture enhancement prepares Conductor OSS for future polyglot capabilities while maintaining 100% backward compatibility with existing workflows.
🤖 Generated with Claude Code