deno icon indicating copy to clipboard operation
deno copied to clipboard

`node:http2` doesn't export `Http2ServerRequest` and `Http2ServerResponse`

Open bartlomieju opened this issue 1 year ago • 8 comments

Discussed in https://github.com/denoland/deno/discussions/23324

Originally posted by OnielN14 April 11, 2024 In the v1.42.2 I see latest compat update for node http2 is released. So I just try to run hono + @hono/node-server

import { serve } from "npm:@hono/node-server"
import { Hono } from "npm:hono"

const app = new Hono()
app.get("/", (c) => c.text("Hello from server"))

serve({
  fetch: app.fetch,
  port: 3000
}, () => {
  console.log("Running on 3000")
})

and it seems Http2ServerRequest is not available as named export. here is the error message

error: Uncaught SyntaxError: The requested module 'http2' does not provide an export named 'Http2ServerRequest'
    at <anonymous> (file:///C:/Users/OnielN14/AppData/Local/deno/npm/registry.npmjs.org/@hono/node-server/1.9.1/dist/index.mjs:5:10)

am I missing something regarding node compatiblity?

Thanks

bartlomieju avatar Apr 11 '24 20:04 bartlomieju

No particular reason, it's a bug.

bartlomieju avatar Apr 11 '24 20:04 bartlomieju

Just exporting these two classes (here and here) won't make it work. The response here will be empty

clemg avatar Apr 15 '24 11:04 clemg

That's correct, @satyarohith is working on improving node:http2 module.

bartlomieju avatar Apr 15 '24 12:04 bartlomieju

@bartlomieju Is this issue still open? I mean can I work on this? Is not entirely clear based on your last comment.

If so, I would like to give it a stab c:

jmj0502 avatar May 10 '24 13:05 jmj0502

@bartlomieju Is this issue still open? I mean can I work on this? Is not entirely clear based on your last comment.

If so, I would like to give it a stab c:

Hi, @jmj0502. Please go ahead. Note https://github.com/denoland/deno/issues/23326#issuecomment-2056651490

satyarohith avatar May 11 '24 05:05 satyarohith

@satyarohith cool!

Quick question? Should I work on the implementation describe on the initial consideration of the issue? or are there other changes to be considered for the issue in question? 🤔

jmj0502 avatar May 11 '24 05:05 jmj0502

@satyarohith cool!

Quick question? Should I work on the implementation describe on the initial consideration of the issue? or are there other changes to be considered for the issue in question? 🤔

A good target is to get the example from description working with Deno. Exporting the unavailable methods isn't sufficient to get it working as mentioned here. I'm not entirely sure what exactly is required to get the example to work with Deno. We need to explore why the response is empty and what needs to be done. The scope of it has increased after https://github.com/denoland/deno/issues/23326#issuecomment-2056651490 and I don't think it's a good first issue anymore. But I'm happy to help (You can send me Discord DM) if you're interested to dig deeper. :)

satyarohith avatar May 11 '24 06:05 satyarohith

A good target is to get the example from https://github.com/denoland/deno/issues/23326#issue-2238489014 working with Deno. Exporting the unavailable methods isn't sufficient to get it working as mentioned https://github.com/denoland/deno/issues/23326#issuecomment-2056651490. I'm not entirely sure what exactly is required to get the example to work with Deno. We need to explore why the response is empty and what needs to be done. The scope of it has increased after https://github.com/denoland/deno/issues/23326#issuecomment-2056651490 and I don't think it's a good first issue anymore. But I'm happy to help (You can send me Discord DM) if you're interested to dig deeper. :)

@satyarohith Cool! I'm all up for it! Many thanks for offering your help, again I don't really know the codebase in depth, but I'll do my best to fix the issue in question.

I'll start by building the project and replicating the issue in question, then I'll proceed to send you a discord DM to further explain my plan of action and start diving deeper into the issue. Feel free to assign the issue to me if you consider it appropriate 👍

jmj0502 avatar May 13 '24 01:05 jmj0502

I also encountered the same issue

EdamAme-x avatar May 31 '24 05:05 EdamAme-x

I'm also experiencing a similar issue with the Astro adapter.

PS C:\Users\user.name\Source\project\packages\web\frontend> npm run build  

> [email protected] build
> astro build

The requested module 'node:http2' does not provide an export named 'Http2ServerResponse' at file:///C:/Users/user.name/Source/project/node_modules/.deno/[email protected]/node_modules/astro/dist/vite-plugin-astro-server/response.js:1:10
  Stack trace:
    at async runCommand (file:///C:/Users/user.name/Source/project/node_modules/.deno/[email protected]/node_modules/astro/dist/cli/index.js:146:25)
npm error Lifecycle script `build` failed with error:
npm error code 1
npm error path C:\Users\user.name\Source\project\packages\web\frontend
npm error workspace [email protected]
npm error location C:\Users\user.name\Source\project\packages\web\frontend
npm error command failed
npm error command C:\WINDOWS\system32\cmd.exe /d /s /c astro build
PS C:\Users\user.name\Source\project\packages\web\frontend> 

und-miller avatar Oct 14 '24 17:10 und-miller

@und-miller what deno version are you using? can you upgrade to the latest version and try again?

satyarohith avatar Oct 14 '24 17:10 satyarohith

@und-miller make sure you're using the latest Deno release. This problem was fixed just a few weeks ago.

bartlomieju avatar Oct 14 '24 18:10 bartlomieju

Thank you for the quick reply. I was indeed running an older version of Deno. After upgrading the problem went away.

und-miller avatar Oct 14 '24 18:10 und-miller