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

Handle all (relevant) Http2Stream events #4

Closed
6 tasks done
grantila opened this issue Oct 31, 2017 · 10 comments
Closed
6 tasks done

Handle all (relevant) Http2Stream events #4

grantila opened this issue Oct 31, 2017 · 10 comments

Comments

@grantila
Copy link
Owner

grantila commented Oct 31, 2017

As said in #1, there are Http2Stream events currently not handled. There are different reasons for all of them to not yet having been handled, this is my current thoughts:

  • aborted
    • Will this also invoke error, i.e. could we ignore this?
  • frameError
    • Same
  • timeout
    • Same
  • trailers
    • AFAIK, these can occur after response, which is when the promise is resolved and fetch() is complete (not the body data necessarily). If this should be handled at all, we'd need an optional callback in the options argument to fetch() so that the user can get these trailing headers. Implementation logic (such as cookies) are not allowed to be sent, so fetch-h2 won't internally need to care about these headers.
  • continue
    • The Fetch API clearly forbids the Expect header to be sent in a request, so 100 shouldn't be a valid response. This event should probably reject the flow as it can't happen.
  • headers
    • I'm not sure why a user of fetch() would ever expect a 1xx response, this is usually a set of low-level handshakes. I don't think this should be handled other than perhaps a rejected promise (at least not for now).

Thoughts on this @pranaygp?

@grantila
Copy link
Owner Author

Only trailers left. The rest are failure now, they shouldn't happen. Will keep open until trailers are completely implemented.

@pranaygp
Copy link

Whoops, sorry for not responding to this earlier.

I agree with the optional argument in the fetch call for trailers. something like handleTrailers might be intuitive? Definitely seems intuitive to me.

I also don't think I completely understand how continue works (will need to read up about this).

With headers is it possible to receive a valid response after receiving a 1xx response? If not, then yeah, rejecting might make sense.

In general, It's likely fine to reject a promise as long as we're providing a user some way to identify which one of these things happened from the error object they receive in .catch

@grantila
Copy link
Owner Author

grantila commented Nov 1, 2017

Or onTrailers? Semantics, but still. Perhaps just trailers. We already have onPush.

You're right, it would be very useful to be able to specifically catch these errors, so their constructors must be public. I'll fix that.

Won't close this until all these issues are well defined and documented.

@grantila
Copy link
Owner Author

grantila commented Nov 2, 2017

timeout and aborted errors will be handled in #6. Other errors are rare and are pure Error's. Should likely never happen anyway.

@pranaygp
Copy link

pranaygp commented Nov 2, 2017

That makes sense.

I wonder if frameError is a valid error that could be the client's fault, and not the backend?,

@pranaygp
Copy link

pranaygp commented Nov 2, 2017

In any case, yeah, frameError should rejected the promise with an Error. I think the implementation is correct

@grantila
Copy link
Owner Author

grantila commented Nov 3, 2017

By the way, @pranaygp, you mentioned the body handling previously, this is changed in #5, so now you can send any string, buffer and readable stream as {body}, and a helper {json} for objects that should be sent as JSON (with application/json automatically set).

@pranaygp
Copy link

pranaygp commented Nov 3, 2017 via email

@grantila
Copy link
Owner Author

grantila commented Nov 3, 2017

That's exactly how it's done now, maybe I was unclear in the docs, I'll update it. I meant that you can assign these types to body directly.

@grantila
Copy link
Owner Author

grantila commented Nov 3, 2017

😎 bf5028f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants