Skip to content

fix(core): run data stages tapped after the pipeline is built - #967

Merged
KetanReddy merged 4 commits into
fix/binding-tracker-resolved-node-mapfrom
fix/late-resolve-data-stages
Nov 17, 2026
Merged

KetanReddy merged 4 commits into
fix/binding-tracker-resolved-node-mapfrom
fix/late-resolve-data-stages

Conversation

@shahabdsh

@shahabdsh shahabdsh commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #966 to set the merge order. The two fixes don't depend on each other, and this PR's diff shows only its own change.

DataController builds its data pipeline lazily, the first time anything reads or writes data, and calls resolveDataStages only at that moment. A stage tapped after that never runs, and nothing reports it.

Ordinary plugins hit this. Plugins tap player.hooks.dataController in registration order, and if a plugin registered earlier reads data in its tap (to seed or check a value, say), the pipeline is built right then. A plugin registered later that taps resolveDataStages from its own dataController tap is silently left out. Whether a data middleware runs then depends on plugin order, which the plugin adding it doesn't control.

Why it's needed now

#968 adds a streaming data plugin whose middleware serves large collections from outside the data model. Without this fix, that plugin has to detect being left out and add itself another way:

let inPipeline = false;
dataController.hooks.resolveDataStages.tap(this.name, (pipeline) => {
  inPipeline = true;
  return [...pipeline, this.middleware];
});

// Deferred so every plugin can tap resolveDataStages before the pipeline is built.
queueMicrotask(() => {
  // A plugin registered earlier may have built the pipeline from its own dataController tap.
  if (!inPipeline) dataController.getModel().addMiddleware(this.middleware);
});

Every plugin that adds a data stage would need the same workaround. With this fix, tapping resolveDataStages is enough, and #968 does only that. Its test "serves the collection when a plugin registered before it already read data" fails without this change.

Change

Right after player.hooks.dataController returns, Player calls a new DataController.rebuildPipeline(). If something already built the pipeline, that calls resolveDataStages again and passes the result to PipelinedDataModel.setMiddleware. If nothing did, it does nothing, and the pipeline is built on first use as before. The data lives in the base LocalModel, and the PipelinedDataModel instance and its hooks are kept, so nothing written earlier is lost and listeners on the model stay attached.

There's no intercept, so tapping resolveDataStages never changes a built pipeline by itself. Every stage tapped during the dataController hook is included, whatever the plugin order. A stage tapped after the hook needs a rebuildPipeline() call; on main, such a stage never runs.

Rebuilding calls every resolveDataStages tap again. A tap that creates a new middleware on each call gets a fresh instance at that point; the taps in computed-properties and stage-revert-data reuse theirs, so they're unaffected.

The data controller architecture page now says that Player rebuilds the pipeline after its dataController hook and that a later tap needs rebuildPipeline(), instead of describing the stages as frozen.

Tests

  • data.test.ts: a stage tapped after the first read doesn't run until rebuildPipeline() and then does, data written before the rebuild is kept, an onSet listener on the model still fires after it, and calling it before the pipeline is built leaves the pipeline to be built on first use.
  • player.test.ts: when one plugin reads data in its dataController tap and a later plugin taps resolveDataStages, the later stage runs. When no plugin reads data during setup, resolveDataStages is called once.

The first player.test.ts test fails on main, and also fails here if Player doesn't call rebuildPipeline(). The core/player vitest, eslint, and typecheck targets pass, as do the computed-properties and stage-revert-data suites.

Change Type (required)

Indicate the type of change your pull request is:

  • patch
  • minor
  • major
  • N/A

Does your PR have any documentation updates?

  • Updated docs
  • No Update needed
  • Unable to update docs

DataController builds its data pipeline the first time anything reads or
writes data, and resolveDataStages was only called at that moment. A
plugin that tapped resolveDataStages after another plugin had already
read data from its own dataController tap was silently left out of the
pipeline.

Rebuild the pipeline whenever a stage is tapped after it was built. The
data itself lives in the base LocalModel, and the PipelinedDataModel
instance and its hooks are kept, so nothing written earlier is lost.
@intuit-svc

intuit-svc commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results

Comparison against baseline from main. ⚠️ = regression (>10% slower), ✅ = improvement (>5% faster)

core/player ⚠️

Benchmark Current Baseline Change
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.bar 813.81K ops/s 925.06K ops/s -12.0% ⚠️
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets.1.name 534.34K ops/s 521.10K ops/s +2.5%
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets.01.name 535.53K ops/s 503.37K ops/s +6.4% ✅
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets['01'].name 441.13K ops/s 501.47K ops/s -12.0% ⚠️
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets[01].name 482.55K ops/s 492.83K ops/s -2.1%
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets[name = "frodo"].type 288.23K ops/s 279.80K ops/s +3.0%
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets["name" = "sprinkles"].type 209.51K ops/s 235.69K ops/s -11.1% ⚠️
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets["isDog" = false].type 283.08K ops/s 308.07K ops/s -8.1%
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets["isDog" = true].type 311.01K ops/s 318.65K ops/s -2.4%
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.bar 602.01K ops/s 605.13K ops/s -0.5%
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets.1.name 399.54K ops/s 389.77K ops/s +2.5%
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets.01.name 390.99K ops/s 392.62K ops/s -0.4%
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets['01'].name 340.09K ops/s 358.56K ops/s -5.2%
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets[01].name 392.68K ops/s 393.40K ops/s -0.2%
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets[name = "frodo"].type 244.43K ops/s 250.49K ops/s -2.4%
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets["name" = "sprinkles"].type 196.04K ops/s 200.40K ops/s -2.2%
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets["isDog" = false].type 243.83K ops/s 243.54K ops/s +0.1%
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets["isDog" = true].type 249.41K ops/s 256.20K ops/s -2.6%
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = 1 + 3 (sync) 412.53K ops/s 490.09K ops/s -15.8% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = 1 + 3 (async) 287.57K ops/s 398.74K ops/s -27.9% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: conditional(true, true, false) (sync) 376.65K ops/s 501.45K ops/s -24.9% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: conditional(true, true, false) (async) 326.11K ops/s 441.52K ops/s -26.1% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = conditional({{bar}} > 0, true, false) (sync) 158.03K ops/s 221.46K ops/s -28.6% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = conditional({{bar}} > 0, true, false) (async) 148.86K ops/s 206.12K ops/s -27.8% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = conditional(conditional(true = false, false, true), conditional(false = false, true, false), conditional(true = true, false, true)) (sync) 128.67K ops/s 153.99K ops/s -16.4% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = conditional(conditional(true = false, false, true), conditional(false = false, true, false), conditional(true = true, false, true)) (async) 119.16K ops/s 158.90K ops/s -25.0% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = await(asyncTestFunction(1)) (sync) N/A N/A N/A
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = await(asyncTestFunction(1)) (async) 216.78K ops/s 298.85K ops/s -27.5% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = asyncTestFunction(1) (sync) 330.71K ops/s 344.27K ops/s -3.9%
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = asyncTestFunction(1) (async) 285.07K ops/s 314.43K ops/s -9.3%
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: asyncTestFunction(1) (sync) 832.90K ops/s 942.19K ops/s -11.6% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: asyncTestFunction(1) (async) 662.96K ops/s 742.09K ops/s -10.7% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = conditional(!{{bar}} == false, await(asyncTestFunction(1)), false) (sync) 182.10K ops/s 193.03K ops/s -5.7%
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = conditional(!{{bar}} == false, await(asyncTestFunction(1)), false) (async) 169.78K ops/s 177.43K ops/s -4.3%
core/player/src/view/resolver/__tests__/index.bench.ts > resolver benchmarks > initial resolve 634.62 ops/s 695.31 ops/s -8.7%
core/player/src/view/resolver/__tests__/index.bench.ts > resolver benchmarks > Resolving from cache 18.50K ops/s 21.96K ops/s -15.8% ⚠️
core/player/src/view/resolver/__tests__/index.bench.ts > resolver benchmarks > data changes 2.72K ops/s 3.14K ops/s -13.3% ⚠️
core/player/src/view/resolver/__tests__/index.bench.ts > resolver benchmarks > data changes slow 606.01 ops/s 660.60 ops/s -8.3%

plugins/async-node/core ⚠️

Benchmark Current Baseline Change
plugins/async-node/core/src/__tests__/index.bench.ts > async node benchmarks > Resolve Async Node 1 times 13.34K ops/s 13.80K ops/s -3.3%
plugins/async-node/core/src/__tests__/index.bench.ts > async node benchmarks > Resolve Async Node 5 times 13.17K ops/s 11.81K ops/s +11.6% ✅
plugins/async-node/core/src/__tests__/index.bench.ts > async node benchmarks > Resolve Async Node 10 times 10.52K ops/s 10.29K ops/s +2.2%
plugins/async-node/core/src/__tests__/index.bench.ts > async node benchmarks > Resolve Async Node 50 times 3.01K ops/s 3.26K ops/s -7.9%
plugins/async-node/core/src/__tests__/index.bench.ts > async node benchmarks > Resolve Async Node 100 times 1.61K ops/s 1.29K ops/s +24.8% ✅
plugins/async-node/core/src/__tests__/transform.bench.ts > async transform benchmarks > Resolve Async Node 1 times 7.55K ops/s 7.74K ops/s -2.4%
plugins/async-node/core/src/__tests__/transform.bench.ts > async transform benchmarks > Resolve Async Node 5 times 7.66K ops/s 8.61K ops/s -11.0% ⚠️
plugins/async-node/core/src/__tests__/transform.bench.ts > async transform benchmarks > Resolve Async Node 10 times 5.95K ops/s 7.56K ops/s -21.3% ⚠️
plugins/async-node/core/src/__tests__/transform.bench.ts > async transform benchmarks > Resolve Async Node 50 times 2.39K ops/s 2.84K ops/s -16.0% ⚠️
plugins/async-node/core/src/__tests__/transform.bench.ts > async transform benchmarks > Resolve Async Node 100 times 1.27K ops/s 1.48K ops/s -14.1% ⚠️

react/player

Benchmark Current Baseline Change
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Render asset nested in 1 ReactAssets 550.87 ops/s 581.40 ops/s -5.3%
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Bubble errors nested in 1 ReactAssets 862.32 ops/s 887.17 ops/s -2.8%
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Render asset nested in 5 ReactAssets 602.45 ops/s 601.54 ops/s +0.2%
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Bubble errors nested in 5 ReactAssets 945.96 ops/s 996.91 ops/s -5.1%
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Render asset nested in 10 ReactAssets 573.42 ops/s 600.54 ops/s -4.5%
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Bubble errors nested in 10 ReactAssets 647.93 ops/s 550.59 ops/s +17.7% ✅
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Render asset nested in 50 ReactAssets 451.38 ops/s 425.02 ops/s +6.2% ✅
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Bubble errors nested in 50 ReactAssets 209.80 ops/s 192.67 ops/s +8.9% ✅
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Render asset nested in 100 ReactAssets 371.21 ops/s 346.42 ops/s +7.2% ✅
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Bubble errors nested in 100 ReactAssets 113.96 ops/s 95.61 ops/s +19.2% ✅

@shahabdsh
shahabdsh added this pull request to stack #969 November 10, 2026 20:28
@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 6.6kB (0.11%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
plugins/check-path/core 444.67kB 612 bytes (0.14%) ⬆️
plugins/async-node/core 507.27kB 612 bytes (0.12%) ⬆️
plugins/markdown/core 685.57kB 612 bytes (0.09%) ⬆️
plugins/reference-assets/core 557.27kB 612 bytes (0.11%) ⬆️
plugins/beacon/core 426.27kB 612 bytes (0.14%) ⬆️
plugins/metrics/core 462.83kB 612 bytes (0.13%) ⬆️
core/player 1.03MB 1.71kB (0.17%) ⬆️
plugins/external-state/core 428.94kB 612 bytes (0.14%) ⬆️
plugins/a2ui/core 588.03kB 612 bytes (0.1%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: plugins/metrics/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
MetricsPlugin.native.js 612 bytes 430.49kB 0.14%
view changes for bundle: plugins/check-path/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
CheckPathPlugin.native.js 612 bytes 415.19kB 0.15%
view changes for bundle: plugins/a2ui/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
A2UIPlugin.native.js 612 bytes 494.18kB 0.12%
view changes for bundle: core/player

Assets Changed:

Asset Name Size Change Total Size Change (%)
Player.native.js 612 bytes 428.41kB 0.14%
cjs/index.cjs 365 bytes 203.37kB 0.18%
index.legacy-esm.js 365 bytes 196.66kB 0.19%
index.mjs 365 bytes 196.66kB 0.19%
view changes for bundle: plugins/markdown/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
MarkdownPlugin.native.js 612 bytes 660.18kB 0.09%
view changes for bundle: plugins/reference-assets/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
ReferenceAssetsPlugin.native.js 612 bytes 519.29kB 0.12%
view changes for bundle: plugins/async-node/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
AsyncNodePlugin.native.js 612 bytes 444.0kB 0.14%
view changes for bundle: plugins/beacon/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
BeaconPlugin.native.js 612 bytes 411.8kB 0.15%
view changes for bundle: plugins/external-state/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
ExternalStatePlugin.native.js 612 bytes 409.97kB 0.15%

@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (c911b30) to head (8eb4076).

Additional details and impacted files
@@                     Coverage Diff                      @@
##   fix/binding-tracker-resolved-node-map   #967   +/-   ##
============================================================
============================================================

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


// The pipeline is built on first use, so a stage tapped after that would
// otherwise never run.
this.hooks.resolveDataStages.intercept({

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general not a fan of intercepts because they can cause weird timing issues. Any way we can solve this another way

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the intercept. Player now calls a new DataController.rebuildPipeline() once, right after the dataController hook, so every stage tapped during that hook is included whatever the plugin order, and tapping alone never touches a built pipeline. When nothing read data during setup it does nothing; a new test checks that resolveDataStages runs once in that case. A stage tapped after the hook needs an explicit rebuildPipeline() call.

@KetanReddy KetanReddy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we can work around the intercept thing I think this should be good to go

Replace the resolveDataStages intercept, which rebuilt the pipeline
whenever a stage was tapped after the first read, with one rebuild that
Player runs right after its dataController hook. That covers a plugin
reading data in its own tap before a later plugin taps resolveDataStages.
A stage tapped after the hook calls the new DataController.rebuildPipeline().
@KetanReddy KetanReddy added the patch Increment the patch version when merged label Nov 17, 2026
@KetanReddy
KetanReddy merged commit 42e48c3 into main Nov 17, 2026
20 checks passed
@KetanReddy
KetanReddy deleted the fix/late-resolve-data-stages branch November 17, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Increment the patch version when merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants