-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Don't swallow fetch TypeError as CORS in non-browser environments #1595
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
89de0df
Don't swallow fetch TypeError as CORS in non-browser environments
bhosmer-ant b8a2e61
Use afterEach to restore document stub in CORS tests
bhosmer-ant 5af5343
Merge branch 'main' into fix/bug-015-cors-retry-masks-errors
felixweinberger d194f1d
Use shim pattern for CORS detection instead of globalThis.document check
felixweinberger 492bc99
Merge branch 'main' into fix/bug-015-cors-retry-masks-errors
felixweinberger db62135
Add changeset
felixweinberger 142aa81
Merge branch 'main' into fix/bug-015-cors-retry-masks-errors
felixweinberger 8fa9273
Propagate network TypeError through discoverOAuthServerInfo PRM catch
bhosmer-ant 88d9eea
Apply same TypeError propagation to authInternal cached-state path
bhosmer-ant 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 hidden or 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,9 @@ | ||
| --- | ||
| '@modelcontextprotocol/client': patch | ||
| --- | ||
|
|
||
| Don't swallow fetch `TypeError` as CORS in non-browser environments. Network errors | ||
| (DNS resolution failure, connection refused, invalid URL) in Node.js and Cloudflare | ||
| Workers now propagate from OAuth discovery instead of being silently misattributed | ||
| to CORS and returning `undefined`. This surfaces the real error to callers rather | ||
| than masking it as "metadata not found." |
This file contains hidden or 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 hidden or 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 hidden or 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,13 @@ | ||
| /** | ||
| * Browser runtime shims for client package | ||
| * | ||
| * This file is selected via package.json export conditions when running in a browser. | ||
| */ | ||
| export { CfWorkerJsonSchemaValidator as DefaultJsonSchemaValidator } from '@modelcontextprotocol/core'; | ||
|
|
||
| /** | ||
| * Whether `fetch()` may throw `TypeError` due to CORS. Only true in browser contexts | ||
| * (including Web Workers / Service Workers). In Node.js and Cloudflare Workers, a | ||
| * `TypeError` from `fetch` is always a real network/configuration error. | ||
| */ | ||
| export const CORS_IS_POSSIBLE = true; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.