Skip to content

Ignore stale out-of-order promises in async bindings - #536

Open
dupontbertrand wants to merge 1 commit into
meteor:release-3.1.0from
dupontbertrand:fix/async-stale-binding
Open

dupontbertrand wants to merge 1 commit into
meteor:release-3.1.0from
dupontbertrand:fix/async-stale-binding

Conversation

@dupontbertrand

Copy link
Copy Markdown
Collaborator

Summary

Fixes #514.

When a reactive input driving an async helper (or an async HTML attribute) updates while a previous Promise is still pending, an earlier slower promise settling after a newer one could overwrite the ReactiveVar (or DOM attributes) with a stale value or error.

Change

  • packages/blaze/builtins.js: Track the active autorun generation in _createBinding (latestRun) and pass an isCurrent guard (() => run === latestRun && !comp.stopped) to _setBindingValue so only the latest active run may write to reactiveVar when a promise resolves or rejects.
  • packages/blaze/materializer.js: Apply the same latestRun and updaterComputation?.stopped guard inside updateAttributes before applying awaited attribute values.
  • packages/spacebars-tests/async_tests.js: Add deterministic out-of-order promise resolution/rejection tests across direct, state1 (@pending/@resolved/@rejected), #if, #each..in, #with, and HTML attributes.

Verification

Ran the headless Tinytest suite in test-app both without jQuery (native DOM backend) and with --extra-packages=jquery:

  • Native DOM mode: 432 / 0 / 0 / 432 passed
  • jQuery mode (--extra-packages=jquery): 436 / 0 / 0 / 436 passed

Changelog

@dupontbertrand dupontbertrand mentioned this pull request Nov 11, 2026
31 of 33 tasks

This branch has not been deployed

No deployments
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

⌂ 换网址