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

Fails with http2 in fastify #26088

Open
Krutsch opened this issue Oct 9, 2024 · 6 comments
Open

Fails with http2 in fastify #26088

Krutsch opened this issue Oct 9, 2024 · 6 comments
Labels
bug Something isn't working correctly node compat node:http Issues with `node:http` module - to be fixed with a rewrite

Comments

@Krutsch
Copy link

Krutsch commented Oct 9, 2024

Version: Deno 2, Windows 11

This code:

import Fastify from "fastify";
import { readFile } from "node:fs/promises";
import { join } from "node:path";

const fastify = Fastify({
  http2: true,
  https: {
    key: await readFile(join(process.cwd(), "localhost-key.pem")),
    cert: await readFile(join(process.cwd(), "localhost.pem")),
  },
});
fastify.get("/", (_req, reply) => {
  reply.send("Hello World");
});
await fastify.listen({ port: 3000, host: "::" });

fails with error:

PS C:\Users\...> deno run -A example.ts  
error: Uncaught (in promise) Error: Not implemented: http2.createSecureServer
    at notImplemented (ext:deno_node/_utils.ts:9:9)
    at Object.createSecureServer (node:http2:1296:3)
    at getServerInstance (file:///C:/Users/.../node_modules/fastify/lib/server.js:278:24)
    at createServer (file:///C:/Users/.../node_modules/fastify/lib/server.js:24:18)
    at fastify (file:///C:/Users/.../node_modules/fastify/fastify.js:181:30)
    at file:///C:/Users/.../example.ts:5:17
    at eventLoopTick (ext:core/01_core.js:175:7)

However, it will work without http2 but logs: Not implemented: Server.setTimeout()

@marvinhagemeister marvinhagemeister added bug Something isn't working correctly node compat node:http Issues with `node:http` module - to be fixed with a rewrite labels Oct 10, 2024
@raaymax
Copy link

raaymax commented Oct 11, 2024

Same here. I tried to use vite with vite-plugin-http2-proxy and got the same error.
Additionally in docs there is no info that this is not yet ready...
https://docs.deno.com/api/node/http2/~/createSecureServer

@adamszigeti
Copy link

Deno fails to run Vite as well because of this reason.

@bartlomieju
Copy link
Member

Which version of Vite and Fastify are you using?

@Krutsch
Copy link
Author

Krutsch commented Oct 14, 2024

I am using the latest version - 5.0.0

@adamszigeti
Copy link

In my case, Vite is also the latest version (5.4.9), though the bug is most certainly not in Vite. As I understand, the problem is that Deno's Node compatibility module for http2's createSecureServer throws a "not implemented" error.

Bun will ship this support in their next release (1.1.31 - see: oven-sh/bun#8823, though how stable it will be is yet to be seen given my experiences with their Node compatibility).

I think related issues include: #3326, and it's tracking issue #23714.

@bartlomieju
Copy link
Member

Thanks, I asked @littledivy to take care of it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node compat node:http Issues with `node:http` module - to be fixed with a rewrite
Projects
None yet
Development

No branches or pull requests

5 participants