-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
feat: support async for proxy.bypass #18940
Merged
patak-dev
merged 7 commits into
vitejs:main
from
shulaoda:feat/support-async-for-proxy-bypass
Jan 23, 2025
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b8a931b
feat: support async for proxy.bypass
shulaoda 168e5fa
chore: follow the suggestions
shulaoda 0669534
chore: should return when bypass error on event upgrade
shulaoda 5ec1c3d
chore: output error when bypass failed in ws proxy
sapphi-red be7df7a
chore: update var name
sapphi-red 0d84d54
chore: add test cases
shulaoda e148ce1
fix: test
shulaoda 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
import { expect, test, vi } from 'vitest' | ||
import { browserLogs } from '~utils' | ||
import { browserLogs, isServe, page, serverLogs } from '~utils' | ||
|
||
test('proxy-bypass', async () => { | ||
await vi.waitFor(() => { | ||
expect(browserLogs.join('\n')).toContain('status of 404 (Not Found)') | ||
}) | ||
}) | ||
|
||
test('async-proxy-bypass', async () => { | ||
const content = await page.frame('async-response').content() | ||
expect(content).toContain('Hello after 4 ms (async timeout)') | ||
}) | ||
|
||
test.runIf(isServe)('async-proxy-bypass-with-error', async () => { | ||
await vi.waitFor(() => { | ||
expect(serverLogs.join('\n')).toContain('bypass error') | ||
}) | ||
}) |
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,2 +1,4 @@ | ||
root app<br /> | ||
<iframe src="/nonExistentApp" style="border: 0"></iframe> | ||
<iframe src="/asyncResponse" name="async-response"></iframe> | ||
<iframe src="/asyncThrowingError"></iframe> |
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.
I think it's odd to have to return the path of the proxy as the return value here, after the request for that path has been handled. I think user's would expect either returning
true
or void (no return) should work.But otherwise this completely handles the cases I care about - thank you!
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.
@sapphi-red - please let us know whether you still think returning the path that was just handled makes sense.
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 think it's fine.