-
Notifications
You must be signed in to change notification settings - Fork 740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EnqueueLinks modifies userData
when adding label, causing unexpected behavior
#1725
Comments
I'd vote for always overriding the label, that would be the expected behavior to me. |
Personally, I wouldn't expect a label from my first call of Or said another way, I wouldn't expect |
Well, |
That's fair. We don't use the Request.label shortcut (preferring to be explicit with what we do on |
Well, we can do both - first create a shallow copy, and then override userData.label with label @B4nan should I do a PR with that? |
Yeah, sure, PR welcome. |
Imagine the following code in a page handler function
Then all requests are enqueued with
label: 'footer-link'
, which is quite unexpected. That is due to this code:crawlee/packages/core/src/enqueue_links/shared.ts
Lines 202 to 203 in 6781f12
enqueueLinks
modifies theuserData
object, and adds the label only if it's not present already. A simple workaround in user code is to provide a shallow copy of the data object (userData: { ...data }
).The possible resolutions are two:
enqueueLinks({ userData: {label: 'foo'}, label: 'bar'})
would enqueue requests with the labelbar
).I'm not really sure which variant is better
Full reproduction repository: mvolfik/apify-enqueuelinks-bug
cc @tomasjindra - that's the issue we debugged together
The text was updated successfully, but these errors were encountered: