Repository navigation
feat: support asynchronous Elixir callbacks from JavaScript - #5
Merged
Merged
Conversation
Drive a resumable Javy provider between Promise continuations so host I/O never holds a dirty NIF scheduler. Grant named JSON callbacks per run, own and cancel callback processes with execution, and enforce budgets independently on the host for both backends. Harden private bridge serialization against guest prototype mutations and keep JavaScript diagnostic budgets independent of callback frames. Include public contract regressions, provider source and reproducible builds, and a bounded HTTP capability example. Amp-Thread-ID: https://ampcode.com/threads/T-01a1507b-cf78-7207-87c1-60a651b36fa4 Co-authored-by: Pedro Piñera Buendía <pedro@pepicrft.me>
| runs-on: tuist-linux | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: jdx/mise-action@v2 |
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.
Behavior
Javex.run/3accepts per-run namedcallbacks. JavaScript callsawait Javex.Host.call(name, json); top-level await, sequential calls and genuinely overlappingPromise.allwork with both in-process and Linux-isolated runtimes, in static and dynamic modes.A resumable custom Javy provider releases the Wasm/NIF stack between continuations. Monitored Elixir callback processes receive decoded JSON and an absolute monotonic deadline. Grants, call/concurrency budgets and JSON payload limits are independently validated by the host. Execution completion, callback/overall deadlines, caller death and runtime shutdown cancel owned callback work. Isolated workers use bounded bidirectional IPC without relaxing their OS restrictions.
HTTP stays in application callbacks. The README demonstrates a fixed-destination Finch capability with host-only credentials, streaming response-size checks and propagated deadlines. This does not install browser
fetch, timers, streaming responses or per-call AbortSignal.Adversarial review and fixes
Object.prototype.toJSONsuppressing a terminal quota failure and Map/Array prototype mutation corrupting the private bridge. Capture private intrinsics and serialize protocol records from primitives, without invoking guesttoJSONhooks. Regression scenarios pass on both backends, including escaped UTF-8 names and payloads.max_stderr; regressions preserve the full JS error on both backends.Verification
JAVEX_BUILD=1 CARGO_BUILD_JOBS=1 mise exec -- mix test --cover: 62 tests, 0 failures; 91.17% coverage.Compatibility and limits
Dynamic modules compiled against the previous bundled provider must be recompiled. Custom legacy providers retain synchronous execution. The custom provider is built from pinned Javy 7.0.0 (Javy CLI 8.1.1), not the upstream default binary.
Callbacks are trusted host code outside guest memory/OS limits; applications must bound external I/O and cancel separately owned work. Cancellation cannot undo completed external effects. Snapshot-seeded
Math.randommay repeat and is not cryptographically secure. Local execution was verified on Linux x86_64; other supported architectures remain covered by release packaging tests, not this orb.