Skip to content

Commit 57af58e

Browse files
committed
Do a read, not just a resolve, as the value of the cell contents matters for change tracking.
1 parent 34618f8 commit 57af58e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

crates/napi/src/next_api/endpoint.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,22 +269,33 @@ async fn subscribe_issues_and_diags_operation(
269269
}
270270
}
271271

272+
#[turbo_tasks::function(operation)]
273+
fn endpoint_client_changed_operation(
274+
endpoint_op: OperationVc<Box<dyn Endpoint>>,
275+
) -> Vc<Completion> {
276+
endpoint_op.connect().client_changed()
277+
}
278+
272279
#[napi(ts_return_type = "{ __napiType: \"RootTask\" }")]
273280
pub fn endpoint_client_changed_subscribe(
274281
#[napi(ts_arg_type = "{ __napiType: \"Endpoint\" }")] endpoint: External<ExternalEndpoint>,
275282
func: JsFunction,
276283
) -> napi::Result<External<RootTask>> {
277284
let turbo_tasks = endpoint.turbo_tasks().clone();
278-
let endpoint = ***endpoint;
285+
let endpoint_op = ***endpoint;
279286
subscribe(
280287
turbo_tasks,
281288
func,
282289
move || {
283290
async move {
284-
let changed = endpoint.connect().client_changed();
291+
let changed_op = endpoint_client_changed_operation(endpoint_op);
285292
// We don't capture issues and diagnostics here since we don't want to be
286293
// notified when they change
287-
changed.strongly_consistent().await?;
294+
//
295+
// This must be a *read*, not just a resolve, because we need the root task created
296+
// by `subscribe` to re-run when the `Completion`'s value changes (via equality),
297+
// even if the cell id doesn't change.
298+
let _ = changed_op.read_strongly_consistent().await?;
288299
Ok(())
289300
}
290301
.instrument(tracing::info_span!("client changes subscription"))

0 commit comments

Comments
 (0)