-
Notifications
You must be signed in to change notification settings - Fork 84
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
Error message not received by connect-node client #1404
Comments
Thanks for the report. This looks like a bug in Node.js: When a res.writeHead(200, {
"msg1": "foo ",
"msg2": "foo%20",
"msg3": " foo",
"msg4": "%20foo",
}); The headers are received as expected with
But a Node.js
Script to reproduceimport { createServer, connect } from "node:http2";
const port = 8011;
const server = createServer(async (req, res) => {
for await (const _ of req) {
//
}
res.writeHead(200, {
"msg1": "foo ",
"msg2": "foo%20",
"msg3": " foo",
"msg4": "%20foo",
});
res.end();
});
server.listen(port, () => {
// Alternatively, comment out call(), and run:
// curl -v http://localhost:8011 --http2-prior-knowledge
call();
});
function call() {
const client = connect(`http://localhost:${port}`);
client.on("error", (err) => console.error(err));
const req = client.request({
":path": "/",
});
req.on("response", (headers, flags) => {
console.log("client received response headers:", headers);
});
req.on("end", () => {
client.close();
server.close();
});
req.end();
} |
Hi @timostamm is this the same bug I found regarding?:
I reproduced the bug here: https://github.com/bobaaaaa/connect-fastify-bug If not, I can create a new issue. |
@mashiro, I've filed nodejs/node#56703. This issue most likely also affects From my understanding, leading or trailing space in a header field is either malformed or should be trimmed in HTTP/2. See details in the linked Node.js issue. The grammar in the gRPC spec may not take this into account. I recommend not to use error messages with leading or trailing whitespace in gRPC because the behavior is implementation-specific (although Node.js certainly stands out by dropping headers completely). As a workaround, you can try to percent-encode error messages before you pass them to the gRPC implementation. Alternatively, or additionally, you can encode the error in a I'm going to close this issue, and hope that the upstream bug is fixed soon. |
@bobaaaaa, this looks like a separate issue, please feel free to create a new one. |
Describe the bug
When grpc-transport is used in connect client, grpc-message is lost if the gRPC server includes a space at the end of the error message.
To Reproduce
Minimum implementation is here.
https://github.com/mashiro/connect-node-test
This is the case for the server implementation of connect-node.
The space is percent encoded and the message is retrieved correctly.
Next is the case of the server implementation of grpc-ruby.
In this implementation, spaces are not percent encoded and messages are lost on connect-node clients.
Space is part of Percent-Byte-Unencoded, it appears that the grpc-ruby implementation must also be able to handle it properly.
https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#responses
Environment (please complete the following information):
2.0.1
The text was updated successfully, but these errors were encountered: