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

gRPC client failing because of stream premature close error. #14249

Open
pablojimpas opened this issue Sep 30, 2024 · 0 comments
Open

gRPC client failing because of stream premature close error. #14249

pablojimpas opened this issue Sep 30, 2024 · 0 comments
Assignees
Labels
bug Something isn't working node:http2

Comments

@pablojimpas
Copy link

What version of Bun is running?

1.1.29+6d43b3662

What platform is your computer?

Linux 6.10.10-artix1-1 x86_64 unknown

What steps can reproduce the bug?

  1. Clone the demo repo git clone https://github.com/pablojimpas/demo-bug-grpc.
  2. Install dependencies: bun install.
  3. Generate Protocol Buffers code: bun run generate.
  4. Run the program bun run index.ts

What is the expected behavior?

The gRPC calls succeeds and the response message appears in the terminal. This works with Node (I'm testing with Node v18.20.4).

I've included two scripts in the package.json to help debugging this: bun run build-bun and bun run build-node to generate bundles for Bun and Node targets.

Running node bundle-node.js and node bundle-bun.js works, but Bun fails with both bun bundle-node.js and bun bundle-bun.js.

What do you see instead?

An error occurs related to a premature close of a stream (ERR_STREAM_PREMATURE_CLOSE):

15947 |   return message.length ? `[${codeToString(code)}] ${message}` : `[${codeToString(code)}]`;
15948 | }
15949 |
15950 | class ConnectError extends Error {
15951 |   constructor(message, code = Code.Unknown, metadata, outgoingDetails, cause) {
15952 |     super(createMessage(message, code));
            ^
ConnectError: [unknown] Premature close
 code: "2"

      at new ConnectError (/home/pablo/demo-grpc/bundle-node.js:15952:5)
      at from (/home/pablo/demo-grpc/bundle-node.js:15969:14)
      at abort (/home/pablo/demo-grpc/bundle-node.js:19624:30)

430 |     }
431 |     function E(code, message, Base) {
432 |       if (!Base)
433 |         Base = Error;
434 |
435 |         constructor(...args) {
                         ^
error: Premature close
 code: "ERR_STREAM_PREMATURE_CLOSE"

      at new NodeError (node:stream:435:20)
      at node:stream:1014:23

Additional information

This might be an issue related to HTTP2, but I don't know the details of the implementation, notice that I'm using @connectrpc/connect instead of @grpc/grpc-js for the gRPC client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working node:http2
Projects
None yet
Development

No branches or pull requests

3 participants