Skip to content

fix: preserve custom tap options dropped by _tap fast path#227

Merged
alexander-akait merged 2 commits intomainfrom
claude/fix-additional-assets-test-IdN0k
Apr 21, 2026
Merged

fix: preserve custom tap options dropped by _tap fast path#227
alexander-akait merged 2 commits intomainfrom
claude/fix-additional-assets-test-IdN0k

Conversation

@alexander-akait
Copy link
Copy Markdown
Member

The fast path added in 9e9ae4d (fix(perf): improve (#224)) only checks
for a fixed set of properties (before/stage/context/type/fn) before
rebuilding the options descriptor as { type, fn, name }. Any custom
user-provided property - notably webpack's additionalAssets, used by
the processAssets hook - was silently dropped, breaking the webpack
ConfigTestCases > process-assets > additional-assets test.

Tighten the fast-path guard to a strict "only name" check via
Object.keys length, preserving the hidden-class optimization for the
common hook.tap({ name: "X" }, fn) case while restoring correctness
for every other call shape.

claude added 2 commits April 21, 2026 04:00
The fast path added in 9e9ae4d (fix(perf): improve (#224)) only checks
for a fixed set of properties (before/stage/context/type/fn) before
rebuilding the options descriptor as `{ type, fn, name }`. Any custom
user-provided property - notably webpack's `additionalAssets`, used by
the processAssets hook - was silently dropped, breaking the webpack
`ConfigTestCases > process-assets > additional-assets` test.

Tighten the fast-path guard to a strict "only name" check via
Object.keys length, preserving the hidden-class optimization for the
common `hook.tap({ name: "X" }, fn)` case while restoring correctness
for every other call shape.
The previous fix used `Object.keys(options).length === 1` to check
whether the tap options object carries any properties beyond `name`
before taking the fast-path literal construction. `Object.keys`
allocates an intermediate array on every call, costing ~10% on the
common `hook.tap({ name: "X" }, fn)` shape vs the (broken) baseline.

Swapping to a `for...in` scan with an early-break avoids that
allocation and pulls the regression down to within measurement noise
(~3%), while keeping the correctness property - any extra user-
supplied key (e.g. webpack's `additionalAssets`) forces the safe
`Object.assign` slow path.

Benchmarked locally with tinybench, 10 taps per iteration, mean of
three runs:

  shape                      broken     for-in     delta
  string                     2.66M      2.50M      -6%
  {name}                     2.16M      2.10M      -3%
  {name,stage}               1.01M      0.98M      -3%
  {name,additionalAssets}    2.19M      1.15M      -48% *
  {name,before}              511K       491K       -4%

  * inherent: this shape must now take the correct slow path since
    the previous "fast" speed was produced by dropping the property.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 21, 2026

⚠️ No Changeset found

Latest commit: 4622404

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@linux-foundation-easycla
Copy link
Copy Markdown

CLA Not Signed

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.35%. Comparing base (5da5021) to head (4622404).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #227      +/-   ##
==========================================
+ Coverage   99.09%   99.35%   +0.25%     
==========================================
  Files          15       15              
  Lines         775      775              
  Branches      132      128       -4     
==========================================
+ Hits          768      770       +2     
+ Misses          7        5       -2     
Flag Coverage Δ
integration 99.35% <100.00%> (+0.25%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 21, 2026

Merging this PR will not alter performance

✅ 92 untouched benchmarks


Comparing claude/fix-additional-assets-test-IdN0k (4622404) with main (5da5021)

Open in CodSpeed

@alexander-akait alexander-akait merged commit 780b3c0 into main Apr 21, 2026
33 of 34 checks passed
@alexander-akait alexander-akait deleted the claude/fix-additional-assets-test-IdN0k branch April 21, 2026 04:37
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.

2 participants