question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cookie not added to cookieJar because of silent error

See original GitHub issue

Summary

It should be convenient to be able to customize RequestJar.setCookie() options, I wanted to debug why a cookie wasn’t collected, and that was apparently because of the following error:

Error: Cookie has domain set to a public suffix
    at CookieJar.setCookie (/projects/veggies/node_modules/tough-cookie/lib/cookie.js:933:13)
    at CookieJar.setCookieSync (/projects/veggies/node_modules/tough-cookie/lib/cookie.js:1305:18)
    at RequestJar.setCookie (/projects/veggies/node_modules/request/lib/cookies.js:28:20)

I had to manually change the way cookies are parsed to actually understand why the cookie were ignored:

// /projects/veggies/node_modules/request/request.js l. 979
targetCookieJar.setCookie(cookie, self.uri.href, {ignoreError: false})

Expected Behavior

Error is raised when I want to.

Current Behavior

Cookie is not set in cookie jar and I have no clue on why it’s not.

Possible Solution

Add ability to pass option to not ignore errors.

Context

I’m trying to get response cookies for a lib I’m writing to help testing APIs using cucumber js, https://github.com/ekino/veggies.

My Environment

software version
request 2.81.0
node 7.6.0
yarn 0.24.5
Operating System OSX 10.12.2

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

4reactions
plouccommented, Jul 3, 2017

I’ve found a workaround to fix my current issue, however it does not change the fact errors should be enabled.

Also accessing internal implementation should be avoided.

cookieJar = request.jar()
cookieJar._jar.rejectPublicSuffixes = false
0reactions
stale[bot]commented, Apr 8, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when loading cookies into a Python request session
Cookie. The Cookie HTTP request header contains stored HTTP cookie previously sent by the server with the Set-Cookie header. A HTTP cookie ......
Read more >
http.cookiejar — Cookie handling for HTTP clients — Python ...
A CookieJar which can load cookies from, and perhaps save cookies to, a file on disk. Cookies are NOT loaded from the named...
Read more >
tough-cookie - npm
creation - Date - modified from construction to when the cookie was added to the jar. lastAccessed - Date - last time the...
Read more >
tough-cookie
12, the allPaths option to cookiejar.getCookies() above will cause the path here to be null . If the path is null , path-matching...
Read more >
22242 (Setting cookie that is too large fails silently)
I could fix this myself, but I would like to hear other's opinions on this, because cookie size limit varies between the browsers,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found