-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Add a fetch test for upload streaming #4362
Add a fetch test for upload streaming #4362
Conversation
Notifying @jdm and @youennf. (Learn how reviewing works.) |
@annevk: This is for whatwg/fetch#425 |
Yeah, testing non-trivial things blindly is very hard, and a good reason to not write all tests up front. Keeping track somewhere of what testing coverage is missing would be nice of course, but only if someone is then using that to guide testing priorities. |
Wait, we're allowing strings to be enqueued? I didn't get that from whatwg/fetch#425 . |
That is a good point and needs to be fixed in the test. Where do we currently place restrictions on what can be on a |
Sorry that was my mistake. Fixed.
At least, Request.text(), etc. expect that as they are using https://fetch.spec.whatwg.org/#concept-read-all-bytes-from-readablestream. |
We should also make the network layer expect that though. And whatever ends up reading a response. |
Yeah I suppose. And we probably need something similar for responses then and make sure all specifications use it… 😟 |
I'm not sure what you're asking for. |
@annevk Tried to run the current test in browser at http://w3c-test.org/tools/runner/index.html. Checked all fetch tests, browser crashed at a worker test. Just want to run the current test. How to do this at *nix, chromium 52? |
What current test? This is a pull request for a test change. It hasn't landed... |
@annevk This test https://github.com/w3c/web-platform-tests/pull/4362/files/3a994b7107795de307eb7039676e130fbf11d9e9..54138da06de3bca241195f1459ae863b4ade77e8. Not well-versed in the terminology and mechanics of git, pull requests. Is it not currently possible to try this now? Is a "pull request" code written that is tested before being published at large? |
You can locally check out the code and run it. I believe for some PRs there's also a URL you can visit, but not for this PR it seems (might depend on where the branch is situated). |
@annevk Is the above referenced test in that repository? Do not need to run all of the tests in the repo, just the newest one, or only the |
The test of this PR is in https://github.com/yutakahirano/web-platform-tests/tree/upload-streaming, a branch in a fork of this repository. If you just want to know whether any browser passes the test, I can tell you that none do, since as I told you elsewhere, this is not implemented yet. |
@annevk Am attempting to gain more knowledge about the entire process. Your feedback has been helpful. |
Basic test: web-platform-tests/wpt#4362. More tests are expected to be written as part of the implementation effort. Further work: #441. Fixes #88.
@yutakahirano perhaps you can also add a test that expects strings and numbers and such to fail. |
Done. |
Thanks, @domenic could you give it another review? |
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.
Some minor test nits. Additionally I have something I am confused about; forgive me if we have discussed it before.
These tests seem to imply that fetch() will read the whole request body stream before fulfilling or rejecting the fetch promise. But, doesn't that hurt our ability to do full-duplex communication with streams? I thought the idea was that you could pass a request body stream, and get back a response body stream, and use them both at the same time. If we wait for the request body stream to be fully read before vending the response body stream, this is not possible, right?
body = body(); | ||
if (body) | ||
requestInit["body"] = body; | ||
return fetch(url, requestInit).then(() => { |
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 should use return promise_rejects(new TypeError(), fetch(url, requestInit))
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.
Done.
testUploadFailure("Fetch with POST with ReadableStream containing number", url, "POST", new ReadableStream({start: controller => { | ||
controller.enqueue(99); | ||
controller.close(); | ||
}})); |
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 should also test ArrayBuffer and Blob are not allowed
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.
Done.
I agree with your assessment of how things should be with regards to full-duplex communication. These tests are simply not testing that scenario, or am I missing something? |
Well, these tests assert bad data causes a rejected promise. How is that possible unless you read to the end before delivering the response? With full duplex you should be able to get a fulfilled promise (with a response you can read from) even if the request contains bad data. Maybe there's a race there and this test is assuming the race resolves in favor of terminating due to bad data before the response is vended? |
I would expect that the default server setup is such that it doesn't emit a response before getting the full request body. It would be good to have tests for early transmitted responses though. |
I see. So is the intent of the spec that there's a race then? If the fetch gets terminated before the promise settles, then the promise is rejected (as in this case); if the fetch gets terminated after the response comes back, the promise is still fulfilled? |
Yeah, the fetch gets terminated so you might not get the whole response body. We should really figure out a way to write full duplex tests since I suspect it is all kinds of broken. |
OK, if that's intended then the tests are good, just the nits in my review remaining. |
Basic tests: web-platform-tests/wpt#4362. More tests are expected to be written as part of the implementation effort. Fixes #88, fixes yutakahirano/fetch-with-streams#10, fixes yutakahirano/fetch-with-streams#57, and fixes yutakahirano/fetch-with-streams#66.
Adding a test for uploading a request made from a ReadableStream.