Skip to content

feat(rong): re-export TaskScope - #49

Merged
butterflyfish merged 1 commit into
masterfrom
feat/export-task-scope
Sep 11, 2026
Merged

butterflyfish merged 1 commit into
masterfrom
feat/export-task-scope

Conversation

@butterflyfish

@butterflyfish butterflyfish commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Why

#43 added TaskScope and begin_task_scope / enter_task_scope / cancel_task_scope to rong_core, and rong_core 0.6.1 shipped them. The rong facade was not bumped, because from the outside nothing in it had changed — but its public API had: it never added TaskScope to 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 JSContext and rong::JSContext is an alias for the core type. The type has no name under rong.

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_core directly, 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

  • rong re-exports TaskScope.
  • rong 0.6.0 → 0.6.1, and a CHANGELOG entry.
  • One test.

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.rs gets 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 with cannot find type TaskScope in this scope, which I checked rather than assumed.

cargo test --features quickjs --test task_scope — 6 passed.

`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
butterflyfish merged commit b772d63 into master Sep 11, 2026
13 checks passed
@butterflyfish
butterflyfish deleted the feat/export-task-scope branch September 11, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant