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

projects like chi v4 deprecate http.CloseNofity and stop working for grpc-web #337

Closed
wuyuanyi135 opened this issue Feb 9, 2019 · 12 comments · Fixed by #478
Closed

projects like chi v4 deprecate http.CloseNofity and stop working for grpc-web #337

wuyuanyi135 opened this issue Feb 9, 2019 · 12 comments · Fixed by #478

Comments

@wuyuanyi135
Copy link

Hi,
I am currently evaluating the grpc frameworks for my next front-end project. I ran into a weird bug this evening. Everything worked in the example project, but the same concept did not work in my project:

2019/02/09 00:35:06 http: panic serving [::1]:43736: interface conversion: *middleware.httpFancyWriter is not http.CloseNotifier: missing method CloseNotify
goroutine 4 [running]:
...
*****/improbable-eng/grpc-web/go/grpcweb.(*grpcWebResponse).CloseNotify(0xc00014c4e0, 0x9e3ac0)
	*****/improbable-eng/grpc-web/go/grpcweb/grpc_web_response.go:52 +0x44

I played around it, and found commenting out this line the error disappeared.
Then, I noticed that go-chi has just gotten a major update (v3->v4), and they are deprecating http.CloseNotifier see this commit. Since this middleware replaces the ResponseWriter to an object without http.CloseNotifier, it breaks the call.

I hope there is a clarification for the example project that the latest chi is not compatible.
Will this project deprecate this API soon?

@wuyuanyi135 wuyuanyi135 changed the title projects like chi deprecate http.CloseNofity and stop working for grpc-web projects like chi v4 deprecate http.CloseNofity and stop working for grpc-web Feb 9, 2019
@johanbrandhorst
Copy link
Contributor

I'm not sure but I think the CloseNotifier is still a requirement of the gRPC.ServeHTTP API. Did you say it was all working without this line in this library code? If you would submit a PR with the changes and we can get the tests passing I don't see why we couldn't remove it though.

@RXminuS
Copy link

RXminuS commented Apr 4, 2019

what's the status of this @wuyuanyi135, why was this closed? It still seems to be a problem

@johanbrandhorst
Copy link
Contributor

@RXminuS thanks for reporting this, would you be interested in contributing a fix for this?

@mangas
Copy link
Contributor

mangas commented Jun 13, 2019

I've just encountered this problem as well. It looks like under src/github.com/improbable-eng/grpc-web/go/grpcweb/grpc_web_response.goline 69 assumes that it is safe to cast the wrapped interface to http.ResponseWriter which in turn doesn't implement the interface anymore.

Looking at it the quick fix seems like it could be just add a switch case but I'm not sure if that wouldn't have wider implications. Any thoughts? @johanbrandhorst

@johanbrandhorst
Copy link
Contributor

I think we can use the precedent set by grpc-go (grpc/grpc-go#2694) and simply remove these methods. @mangas would you be interested in contributing this fix?

@mangas
Copy link
Contributor

mangas commented Jun 13, 2019

That seems like a much bigger change, would you fine with me proposed solution?

@johanbrandhorst
Copy link
Contributor

I don't see how you could implement this with a type switch. What would you return if it doesn't implement it? A nil channel would potentially crash the program instead. Just remove the function.

@mangas
Copy link
Contributor

mangas commented Jun 13, 2019

I was going to add a channel to the struct that we'd return in that case. The function is being called, I assume that comes from the actual grpc-server implementation.

@johanbrandhorst
Copy link
Contributor

The gRPC server doesn't use the method. It has been deprecated in Go since context was introduced in 1.7 (I think?). We should just remove it from our methods now that we have several releases since the deprecation.

@mangas
Copy link
Contributor

mangas commented Jun 13, 2019

It seems like Flusher is another issue, are you aware of a bug report for it? Same situation, interface cast without a check as far as I understand it

@johanbrandhorst
Copy link
Contributor

Flusher is not deprecated, so we can't remove that, and we probably still want to support that. We could perhaps consider a type switch there, but is there actually a problem? If you find an issue with it (other than just a suspicion from looking at the code), please raise a separate issue.

@mangas
Copy link
Contributor

mangas commented Jun 13, 2019

Yeah, will do. I'm still investigating, the. issue is come from the usage of a wrapper library that provides tracing capabilities but only implements the standard http.ResponseWriter interfaces

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

Successfully merging a pull request may close this issue.

4 participants