-
-
Notifications
You must be signed in to change notification settings - Fork 366
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 multipart boundary mismatch #540
Merged
sindresorhus
merged 3 commits into
sindresorhus:main
from
kdelmonte:multipart-boundary-mismatch
Oct 29, 2023
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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 |
---|---|---|
@@ -1,19 +1,28 @@ | ||
/* eslint-disable ava/no-ignored-test-files */ | ||
import process from 'node:process'; | ||
import type {ExecutionContext, Implementation} from 'ava'; | ||
import {chromium, type Page} from 'playwright-chromium'; | ||
import test from 'ava'; | ||
import {chromium, firefox, webkit, type BrowserType, type Page} from 'playwright'; | ||
import type {ExecutionContext} from 'ava'; | ||
|
||
type Run = (t: ExecutionContext, page: Page) => Promise<void>; | ||
|
||
const PWDEBUG = Boolean(process.env['PWDEBUG']); | ||
const DEFAULT_BROWSERS = [chromium, firefox, webkit]; | ||
|
||
export const withPage: Implementation<any[]> = async (t: ExecutionContext, run: Run): Promise<void> => { | ||
const browser = await chromium.launch({ | ||
devtools: PWDEBUG, | ||
}); | ||
const page = await browser.newPage(); | ||
try { | ||
await run(t, page); | ||
} finally { | ||
await browser.close(); | ||
export const browserTest = (title: string, browserTypes: BrowserType[], run: Run) => { | ||
for (const browserType of browserTypes) { | ||
test.serial(`${browserType.name()} - ${title}`, async t => { | ||
const browser = await browserType.launch({devtools: PWDEBUG}); | ||
const page = await browser.newPage(); | ||
try { | ||
await run(t, page); | ||
} finally { | ||
await browser.close(); | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
export const defaultBrowsersTest = (title: string, run: Run) => { | ||
browserTest(title, DEFAULT_BROWSERS, run); | ||
}; |
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.
Is there any other way than having a hard-coded list here? We'll have to keep this up to date and if we miss something, it could cause problems.
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.
I really want to avoid this too. Let me give it some thought.
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.
Maybe a similar solution to the
KyOptionsRegistry
can be employed here to defer the list keeping to Typescript and undici. I will try this.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.
So there are two RequestInit interfaces that are relevant here: the one exported from node's
undici-types
and the one exported from Typescript'slib.dom.d.ts
.Common fields present in both interfaces:
method
keepalive
headers
body
redirect
integrity
signal
credentials
mode
referrer
referrerPolicy
window
Unique to
undici-types
:dispatcher
duplex
Unique to Typescript's
lib.dom.d.ts
:cache
Standard Request Options as specified in MDN
Present in both
undici-types
andlib.dom.d.ts
:method
headers
body
mode
credentials
redirect
referrer
referrerPolicy
integrity
keepalive
signal
Present only in
lib.dom.d.ts
:cache
Missing in both
undici-types
andlib.dom.d.ts
:priority
(With all of this being said, I think we can leave
priority
out and let it be detected as an unknown property since it will still be passed down to fetch.Please let me know what you think of this approach @sindresorhus and @sholladay.
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.
Yeah, that sounds like a good approach.