Skip to content

fix: cookies setting in preNavigationHooks#1283

Merged
B4nan merged 1 commit intomasterfrom
fix/cookies-in-prenavigation-hooks
Jan 16, 2022
Merged

fix: cookies setting in preNavigationHooks#1283
B4nan merged 1 commit intomasterfrom
fix/cookies-in-prenavigation-hooks

Conversation

@AndreyBykov
Copy link
Copy Markdown
Contributor

@AndreyBykov AndreyBykov commented Jan 15, 2022

This issue #1266 is kinda solved in the latest beta, but while testing I stuck upon an edge case when you try to set only one cookie (like mentioned in the issue), which leads to cookies array here having an actual cookie and a second item, which is gonna be an empty string, which is leading to:

TypeError: Cannot read properties of undefined (reading 'key')
      at /Users/AndreyBykov/Documents/Apify/Playground/playground/node_modules/apify/build/crawlers/crawler_utils.js:52:31
      at Array.find (<anonymous>)
      at mergeCookies (/Users/AndreyBykov/Documents/Apify/Playground/playground/node_modules/apify/build/crawlers/crawler_utils.js:51:62)
      at CheerioCrawler._mergeRequestCookieDiff (/Users/AndreyBykov/Documents/Apify/Playground/playground/node_modules/apify/build/crawlers/cheerio_crawler.js:570:87)
      at CheerioCrawler._handleNavigation (/Users/AndreyBykov/Documents/Apify/Playground/playground/node_modules/apify/build/crawlers/cheerio_crawler.js:540:14)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async CheerioCrawler._handleRequestFunction (/Users/AndreyBykov/Documents/Apify/Playground/playground/node_modules/apify/build/crawlers/cheerio_crawler.js:475:9)
      at async wrap (/Users/AndreyBykov/Documents/Apify/Playground/playground/node_modules/@apify/timeout/index.js:73:27)

Closes #1266

@AndreyBykov AndreyBykov requested a review from B4nan January 15, 2022 23:15
@AndreyBykov AndreyBykov changed the title fix cookies setting in preNavigationHooks fix: cookies setting in preNavigationHooks Jan 15, 2022
@AndreyBykov AndreyBykov linked an issue Jan 15, 2022 that may be closed by this pull request
@B4nan B4nan merged commit 178d6e3 into master Jan 16, 2022
@B4nan B4nan deleted the fix/cookies-in-prenavigation-hooks branch January 16, 2022 09:09
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.

diffCookies error when working with cookies in CheerioCrawler

2 participants