-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Use tough-cookie CookieJar sync API #767
Conversation
cc @lalitkapoor |
try { | ||
targetCookieJar.setCookie(cookie, self.uri.href); | ||
} catch (e) { | ||
self.emit('cookieError', e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this is better than the console.warn
- let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when/where would this error?
you might want to just emit an error normally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The real-world failures should be quite limited; egregious formatting errors for the cookie or the domain. I'll change this to .emit('error')
@stash this definitely makes it more friendly. I tried to build a cleaner interface for using tough-cookie here: https://github.com/lalitkapoor/request-cookies (needs to be refactored to use sync api now). What are your thoughts? On a side note I have some ideas for implementing sync differently, but I'll post that on goinstant/node-cookie instead of here. |
@lalitkapoor definitely take what I've got in this branch's |
@mikeal ok, changed that line to |
Use tough-cookie CookieJar sync API
Use tough-cookie CookieJar sync API
This restores backwards-compatibility with
jar
parameters (i.e. jar.setCookie takes two parameters and is guaranteed synchronous).The async API for tough-cookie can't be used without major changes to
request
itself, so I've left that for another day.