Testing a single context, IIFE-based approach to isolating vars set i…#2886
Merged
amanjeetsingh150 merged 3 commits intomainfrom Mar 17, 2026
Merged
Testing a single context, IIFE-based approach to isolating vars set i…#2886amanjeetsingh150 merged 3 commits intomainfrom
amanjeetsingh150 merged 3 commits intomainfrom
Conversation
steviec
commented
Dec 15, 2025
Comment on lines
+148
to
+152
| // Clear non-permanent (env) bindings, then set current env vars | ||
| bindings.memberKeys | ||
| .filter { it !in permanentBindingKeys } | ||
| .forEach { bindings.removeMember(it) } | ||
| envBinding.forEach { (k, v) -> bindings.putMember(k, v) } |
Collaborator
Author
There was a problem hiding this comment.
Note that this would be much cleaner if we just made ENV variables available on a named binding for it, e.g. env instead of putting them directly on the context root.
amanjeetsingh150
approved these changes
Mar 16, 2026
Leland-Takamine
approved these changes
Mar 16, 2026
3150718 to
e365c98
Compare
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.
Proposed changes
Graal JS contexts take almost a full 1MB of memory, and if we have a repeated loop of commands, we can easily hit 1000+ commands (with associated contexts). The contexts are only cleared when the full maestro flow is done executing, which means we can bloat our memory considerably.
However, if we close a context, then values that have been stored on our
outputormaestroobjects will get wiped. So we need to keep those values around.This PR keeps a single, shared context, which guarantees that
outputandmaestroobjects persist across invocations. It uses IIFE to isolate vars defined in the user script, and has to do additional management of the dynamic env vars to maintain our sub scope logic.Testing
See test suite to understand how this was tested. The tests are identical to the other PR: #2881.