Skip to content

node:http2.createServer fails for h2c (cleartext HTTP/2) #29073

@kevgeoleo

Description

@kevgeoleo

What version of Bun is running?

1.3.11-canary.1+9e93bfa1b

What platform is your computer?

Linux 5.10.0-12-amd64 x86_64 x86_64

What steps can reproduce the bug?

Hi,

I would like to report a behavior in Bun that can be reproduced by running the below snippet:

import http2 from "node:http2";

const server = http2.createServer((req, res) => {
  res.setHeader("Content-Type", "text/html");
  res.setHeader("X-Foo", "bar");
  res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" });
  res.end("ok");
});

server.listen(8000);

What is the expected behavior?

root@KContainer:~/22618# fuser -k 8000/tcp || true && (node server.mjs &) && sleep 2 && curl --http2-prior-knowledge http://localhost:8000
8000/tcp:            27639
ok

What do you see instead?

http2.createServer() in Bun accepts a connection but returns an empty reply when using HTTP/2 prior knowledge (h2c), while the same code works correctly in Node.js

root@KContainer:~/22618fuser -k 8000/tcp || true && (bun run server.mjs &) && sleep 2 && curl --http2-prior-knowledge http://localhost:8000
8000/tcp:            27828
curl: (52) Empty reply from server

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions