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

HTTP2 - sending server trailers #10214

Closed
prohazko2 opened this issue Apr 16, 2021 · 4 comments
Closed

HTTP2 - sending server trailers #10214

prohazko2 opened this issue Apr 16, 2021 · 4 comments

Comments

@prohazko2
Copy link

Hi,

Was playing around with gRPC implementation and almost succeed with basic unary calls serving
https://github.com/prohazko2/deno-grpc/blob/0.1.3/serve.ts

  1. http2 with Deno.serveHttp was ok
  2. protobuf msgs decoding/encoding with protobuf.js was ok
  3. thing that I didn't figure out - how to send OK status back to client

Similar node's @grpc/grpc-js response has two server trailers:

[0] Received server trailers:
		grpc-status: 0
		grpc-message: OK

[0] received status code 0 from server
[0] received status details string "OK" from server

Seems like they are sent with this call to node http2stream.sendTrailers
@grpc/grpc-js@1.3.x ... server-call.ts

But I didn't have any luck with sending them with Deno's respondWith / Response API's

@kitsonk
Copy link
Contributor

kitsonk commented Apr 16, 2021

I haven't tried it yet, but I believe the way it should work is set response.trailers to a promise that resolves with a headers object with the trailing headers (that is according to the Response standard).

@lucacasonato
Copy link
Member

lucacasonato commented Apr 16, 2021

Trailers are not supported in the fetch spec anymore, and likely will not be re-introduced unless there is significant demand: whatwg/fetch#981. I don't think we will be supporting them either if the web does not. Removal happened in whatwg/fetch#772.

@kitsonk
Copy link
Contributor

kitsonk commented Apr 17, 2021

Looking at this more, it feels like instead of "trailers" you want to do something like SSE... where you return a ReadableStream as a body, and continue to .enqueue() Uint8Arrays in the streams controller for as long as you need before closing the controller and ending the response.

@prohazko2
Copy link
Author

Thanks, will try.
Also closing issue since trailers out of spec

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

3 participants