feat(rong): re-export TaskScope - #49
Merged
Merged
Conversation
butterflyfish
force-pushed
the
feat/export-task-scope
branch
from
September 11, 2026 16:23
6f533fe to
142662f
Compare
`rong_core` 0.6.1 added `TaskScope` and the three context methods that open, switch and cancel one. The methods came through the `rong` facade for free — they are inherent on `JSContext`, which is an alias for the core type — but the type itself was never added to the re-export list, so under `rong` it has no name. That is enough to use a scope and not enough to embed one. An embedder opening a scope per request opens it where the request starts and cancels it where the request ends; in between the value lives in a field, and a field has to be written with a type. Reaching into `rong_core` to name it would mean depending on the crate the facade exists to cover. The existing tests did not catch this because every one of them takes the type from inference, inside a single function. The new one stores a scope in a struct and cancels it from there, which is the shape an embedder actually has, and it fails to compile without the re-export.
butterflyfish
force-pushed
the
feat/export-task-scope
branch
from
September 11, 2026 16:27
142662f to
d3f9178
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.
Why
#43 added
TaskScopeandbegin_task_scope/enter_task_scope/cancel_task_scopetorong_core, androng_core0.6.1 shipped them. Therongfacade was not bumped, because from the outside nothing in it had changed — but its public API had: it never addedTaskScopeto its re-export list.The result is a surface that is half-usable. The three methods come through for free, because they are inherent on
JSContextandrong::JSContextis an alias for the core type. The type has no name underrong.That is enough to use a scope and not enough to embed one. The whole point of the feature is one scope per logical request: open it where the request starts, cancel it where the request ends. Those are two different functions, so in between the value lives in a field — and a field has to be written with a type. Naming it means depending on
rong_coredirectly, which is the crate the facade exists to cover.This is not hypothetical: it is what blocked LingXiao from wiring #43 into its runtime, where the scope has to be carried on the struct that does post-response cleanup. It cannot use
current_task_scope()as a substitute, because the next request is admitted before the previous one's cleanup runs, so "the current scope" at cleanup time can be the live request's.What
rongre-exportsTaskScope.rong0.6.0 → 0.6.1, and a CHANGELOG entry.The CHANGELOG entry sits at the end of
[Unreleased]rather than under the heading, so it does not collide with #50's insert at the top of the same section.About the test
Every existing test in
tests/task_scope.rsgets the type from inference, inside a single function — which is exactly why none of them noticed. The new one stores a scope in a struct and cancels it from there, the shape an embedder actually has. Removing the re-export fails it at compile time withcannot find type TaskScope in this scope, which I checked rather than assumed.cargo test --features quickjs --test task_scope— 6 passed.