-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix validation errors not calling callbacks (#424)
* I noticed this issue while upgrading `tough-cookie` in `jsdom` which was causing their test suite to hang. There is a sneaky little bug around our internal validations where, in several methods that accept callbacks, our validations error out directly and never invoke the given callback with the error. This can lead to code that waits for a callback that will never complete. This also affects functions wrapped in `Sync` which leverage callbacks to capture their return values. The affected methods were: - `getCookiesSync` - `getCookieString` - `getSetCookieStrings` - `serializeSync` - `serialize` - `setCookieSync` - `setCookie` - `getCookiesSync` - `getCookies` There were also several validation errors hiding in support methods. These appear to be redundant since the type signatures present already do much of the validation. These have been removed from: - `checkSameSiteContext` - `isHostPrefixConditionMet` - `isSecurePrefixConditionMet` - `cookieCompare` - `formatDate` - `permutePath` * Fix lint error * Fix incorrect test * Addressing code review comments
- Loading branch information
1 parent
972efeb
commit 120058c
Showing
13 changed files
with
213 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [CookieJar](./tough-cookie.cookiejar.md) > [getCookies](./tough-cookie.cookiejar.getcookies_3.md) | ||
|
||
## CookieJar.getCookies() method | ||
|
||
Retrieve the list of cookies that can be sent in a Cookie header for the current URL. | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
getCookies(url: string | URL, options?: GetCookiesOptions | undefined): Promise<Cookie[]>; | ||
``` | ||
|
||
## Parameters | ||
|
||
<table><thead><tr><th> | ||
|
||
Parameter | ||
|
||
|
||
</th><th> | ||
|
||
Type | ||
|
||
|
||
</th><th> | ||
|
||
Description | ||
|
||
|
||
</th></tr></thead> | ||
<tbody><tr><td> | ||
|
||
url | ||
|
||
|
||
</td><td> | ||
|
||
string \| URL | ||
|
||
|
||
</td><td> | ||
|
||
The domain to store the cookie with. | ||
|
||
|
||
</td></tr> | ||
<tr><td> | ||
|
||
options | ||
|
||
|
||
</td><td> | ||
|
||
[GetCookiesOptions](./tough-cookie.getcookiesoptions.md) \| undefined | ||
|
||
|
||
</td><td> | ||
|
||
_(Optional)_ Configuration settings to use when retrieving the cookies. | ||
|
||
|
||
</td></tr> | ||
</tbody></table> | ||
**Returns:** | ||
|
||
Promise<[Cookie](./tough-cookie.cookie.md)<!-- -->\[\]> | ||
|
||
## Remarks | ||
|
||
- The array of cookies returned will be sorted according to [cookieCompare()](./tough-cookie.cookiecompare.md)<!-- -->. | ||
|
||
- The [Cookie.lastAccessed](./tough-cookie.cookie.lastaccessed.md) property will be updated on all returned cookies. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.