-
-
Notifications
You must be signed in to change notification settings - Fork 509
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
fix: parse "Set-Cookie" response header with commas correctly #2075
Merged
kettanaito
merged 8 commits into
mswjs:main
from
ushiboy:feature/getting-response-cookies
Mar 15, 2024
+10
−4
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
62c1626
fix: add test for cookies containing commas
2c94166
fix: getting response cookies
52eaf0d
Merge branch 'main' into feature/getting-response-cookies
ushiboy a395407
Merge branch 'mswjs:main' into feature/getting-response-cookies
ushiboy 71702da
fix: changed to a temporary process with polyfill
2ff9dfe
fix: comment typo
66e9e58
fix: change comment to indicate the reason
91802bb
Merge branch 'main' into feature/getting-response-cookies
ushiboy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We shouldn't tailor to technologies that violate standard support. We should rely on
.getSetCookie()
because it's a supported method. If the underlying environment doesn't support it, it's the underlying environment that should be fixing it (i.e. including any necessary polyfills). We mustn't rely onheaders-polyfill
anymore. It's used only for its utilities around transforming headers.The only concern is what @mattcosta7 raised about the TypeScript supporting this method. It doesn't exist on earlier versions of TS:
And seems to only land in 5.2.
The
Headers.prototype.getSetCookie
can also be used only since Node.js 19 (which translates to v20 for stable releases) while MSW supports v18.With this in mind, we cannot ship
.getSetCookie()
method as a part of MSW—it will break for a lot of people because it won't exist type-wise and runtime-wise.We need to implement the logic/fix ourselves until TS 5.2 and Node.js v20 become the minimal supported versions, which is years in the future.
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.
TL;DR
What you're doing is fine. Just the reasoning should be mentioned more prominently above this line.
Can you please include a comment above this
HeadersPolyfill
usage briefly describing why we rely on a polyfill here? Thanks!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.
FWIW - typescript not supporting this in 4.7-5.1 shouldn't matter for consumers using those versions, because this call is encapsulated from their tooling (it's internal and generally node_modules aren't typechecked except at their
.d.ts
level which shouldn't contain any information about this call to getSetCookieBut with neither node18, jest not vitest able to support this correctly, we'd basically break everyone's tests the second we shipped it which would be unideal.
I'm very much onboard that jsdom needs to support this - although maybe one day people will test browser code in a browser....one day
We could also inline logic from the headerpolyfill here instead of using that directly, as another option to get away from the polyfill - it's just implemented there already
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.
This is only true if they have
skipLibCheck: true
, which is not the default and many people still have it disabled, which will cause compilation problems. Granted, easy to fix but creates an unnecessary stress for consumers.Fingers crossed!
See no reason to duplicate code. We depend on
headers-polyfill
anyway right now, its implementation is tested, we should use it.