Skip to content
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

Reject the Promise returned by fetch() when Request ctor throws #217

Merged
merged 1 commit into from
Oct 10, 2015

Conversation

bryanrsmith
Copy link
Contributor

This solves part of what #132 does, but that PR seems abandoned.

https://fetch.spec.whatwg.org/#dom-global-fetch step 2 states that exceptions thrown by the Request constructor should cause fetch() to reject with the error. Exceptions thrown synchronously in the Promise callback will cause a rejection, so I've simply moved the Request ctor call into the Promise callback.

Manually verified that tests pass with native fetch implementations in Chrome and Firefox.

@@ -601,8 +609,7 @@ suite('Methods', function() {
})
})

// TODO: Waiting to verify behavior
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change OK? I'm not sure what this TODO was for, but as far as I can tell the tests appear correct and inline with the spec and current implementations. I needed to enable them to verify that the Request constructor throws under the same conditions I'm using to verify that fetch() rejects.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, right now the Chrome implementation also throws an exception on GET/HEAD with body. There is a suggestion to change the spec to allow bodies for GET requests, but until the spec actually changes, I think these tests are good.

@mislav
Copy link
Contributor

mislav commented Oct 10, 2015

Looks good!

mislav added a commit that referenced this pull request Oct 10, 2015
Reject the Promise returned by fetch() when Request ctor throws
@mislav mislav merged commit bbb1a21 into JakeChampion:master Oct 10, 2015
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants