Skip to content

Conversation

@l2ysho
Copy link

@l2ysho l2ysho commented Jan 29, 2026

The transformRequestFunction in enqueueLinks was being applied before pattern-based filtering (globs, regexps, pseudoUrls), which meant that request options set by patterns would overwrite changes made by transformRequestFunction. This was counterintuitive - users expected transformRequestFunction to have the final say over request modifications.

Solution

Reorder the processing pipeline so that transformRequestFunction is applied after all filtering and pattern matching:

Previous order: transformRequestFunction → Pattern filtering → Request creation
New order: Pattern filtering → Request creation → transformRequestFunction

Changes

packages/core/src/enqueue_links/enqueue_links.ts

  • Moved transformRequestFunction execution to after createFilteredRequests()
  • transformRequestFunction now operates on Request instances instead of RequestOptions
  • Added handling for when transformRequestFunction returns a plain object (converts it to a Request instance)
  • Updated JSDoc comments to clarify the correct precedence:
    • Lowest priority: Global label option
    • Medium priority: Pattern-specific options (globs, regexps, pseudoUrls)
    • Highest priority: transformRequestFunction

test/core/enqueue_links/enqueue_links.test.ts

  • Added comprehensive test suite for label precedence rules covering:
    • Global label as lowest priority
    • Pattern labels overriding global labels
    • transformRequestFunction overriding pattern labels
    • transformRequestFunction modifying other request properties
    • Handling of plain objects returned from transformRequestFunction

closes #3070

@l2ysho l2ysho requested review from B4nan, barjin and janbuchar January 29, 2026 11:45
@l2ysho l2ysho linked an issue Jan 29, 2026 that may be closed by this pull request
@github-actions github-actions bot added this to the 133rd sprint - Tooling team milestone Jan 29, 2026
@github-actions github-actions bot added t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics. labels Jan 29, 2026

return filtered;
// Apply transformRequestFunction after filtering - it has the highest priority
if (transformRequestFunction) {
Copy link
Author

Choose a reason for hiding this comment

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

another option is to pass transformRequestFunction to the createRequest function and do the job there, but then the logic is split to 2 places so I picked this way.

@B4nan
Copy link
Member

B4nan commented Jan 29, 2026

This should target v4 branch

@l2ysho l2ysho changed the base branch from master to v4 January 29, 2026 12:20
@l2ysho l2ysho marked this pull request as draft January 29, 2026 12:21
@l2ysho
Copy link
Author

l2ysho commented Jan 29, 2026

This should target v4 branch

I have to rebase then

@B4nan
Copy link
Member

B4nan commented Jan 29, 2026

That might be a bit too much work, maybe better to recreate the PR (reset your changes, stash, hard reset to v4 upstream, unstash, resolve conflics once...)

@janbuchar
Copy link
Contributor

It's worth trying to cherrypick those two commits 🤷

refactor
refactor

refactor
@l2ysho l2ysho force-pushed the 3070-rectify-transformrequestsfunction-precedence-rules branch from 0af2256 to eb52536 Compare January 29, 2026 12:43
@l2ysho
Copy link
Author

l2ysho commented Jan 29, 2026

That might be a bit too much work, maybe better to recreate the PR (reset your changes, stash, hard reset to v4 upstream, unstash, resolve conflics once...)

It's worth trying to cherrypick those two commits 🤷

It was not so bad

@l2ysho l2ysho marked this pull request as ready for review January 29, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rectify transformRequestsFunction precedence rules

4 participants