You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes `transformRequestFunction` precedence in `enqueueLinks` — it now runs **after** pattern filtering instead of before, giving it the highest priority so its modifications can't be silently overwritten by `globs`/`regexps`/`pseudoUrls` options.
Previously, pattern-specific options (like `method` or `userData` on a glob) would override changes made by `transformRequestFunction`, which was unintuitive since the transform is the user's explicit escape hatch for customizing requests.
**Priority order (lowest to highest):**
1. Global `label`/`userData`
2. Pattern-specific options (`globs`, `regexps`, `pseudoUrls`)
3. `transformRequestFunction`
**What changed:**
- Reordered the processing pipeline: patterns filter and enrich first, then `transformRequestFunction` runs last
- Requests rejected by the transform (returning `null`/`false`) now report a `'transform'` skip reason via `onSkippedRequest`
- Updated Playwright and Puppeteer click-element utilities for consistent behavior
- Added upgrade guide documentation and comprehensive tests
Copy file name to clipboardExpand all lines: docs/upgrading/upgrading_v4.md
+15Lines changed: 15 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,3 +114,18 @@ The `KeyValueStore.getPublicUrl` method is now asynchronous and reads the public
114
114
## `preNavigationHooks` in `HttpCrawler` no longer accepts `gotOptions` object
115
115
116
116
The `preNavigationHooks` option in `HttpCrawler` subclasses no longer accepts the `gotOptions` object as a second parameter. Modify the `crawlingContext` fields (e.g. `.request`) directly instead.
117
+
118
+
## `transformRequestFunction` precedence in `enqueueLinks`
119
+
120
+
The `transformRequestFunction` callback in `enqueueLinks` now runs **after** URL pattern filtering (`globs`, `regexps`, `pseudoUrls`) instead of before. This means it has the highest priority and can overwrite any request options set by patterns or the global `label` option.
121
+
122
+
The priority order is now (lowest to highest):
123
+
1. Global `label` / `userData` options
124
+
2. Pattern-specific options from `globs`, `regexps`, or `pseudoUrls` objects
125
+
3.`transformRequestFunction`
126
+
127
+
The `transformRequestFunction` callback receives a `RequestOptions` object and can return either:
128
+
- The modified `RequestOptions` object
129
+
- A new `RequestOptions` plain object
130
+
-`'unchanged'` to keep the original options as-is
131
+
- A falsy value or `'skip'` to exclude the request from the queue
* Note that the request options specified in `globs`, `regexps`, or `pseudoUrls` objects
149
-
* have priority over this function. Some request options returned by `transformRequestFunction` may be overwritten by pattern-based options from `globs`, `regexps`, or `pseudoUrls`.
149
+
* Note that `transformRequestFunction` has the highest priority and can overwrite request options
150
+
* specified in `globs`, `regexps`, or `pseudoUrls` objects, as well as the global `label` option.
151
+
*
152
+
* The function receives a {@apilink RequestOptions} object and can return either:
153
+
* - The modified {@apilink RequestOptions} object
154
+
* - `'unchanged'` to keep the original options as-is
155
+
* - A falsy value or `'skip'` to exclude the request from the queue
150
156
*/
151
157
transformRequestFunction?: RequestTransform;
152
158
@@ -437,58 +443,59 @@ export async function enqueueLinks(
0 commit comments