Skip to content

[Bug] failed to log ctx.req #339

@HunterGitHub

Description

@HunterGitHub

Nodejs v24
@hono/node-server: "1.19.13"
hono: "4.12.12"

a simple code like this,

import { serve } from '@hono/node-server'
import { Hono } from 'hono'

const app = new Hono()
app.get('/', (c) => {
  console.log('==== c.req', c.req)
  return c.text('Hono meets Node.js')
})

serve(app, (info) => {
  console.log(`Listening on http://localhost:${info.port}`) // Listening on http://localhost:3000
})

and it will report error

TypeError: Cannot read private member #state from an object whose class did not declare it
    at get isReloadNavigation (node:internal/deps/undici/undici:12174:21)
    at [nodejs.util.inspect.custom] (node:internal/deps/undici/undici:12244:36)
    at formatValue (node:internal/util/inspect:897:19)
    at formatProperty (node:internal/util/inspect:2283:11)
    at formatRaw (node:internal/util/inspect:1176:9)
    at formatValue (node:internal/util/inspect:932:10)
    at inspect (node:internal/util/inspect:409:10)
    at formatWithOptionsInternal (node:internal/util/inspect:2645:40)
    at formatWithOptions (node:internal/util/inspect:2507:10)
    at console.value (node:internal/console/constructor:360:14)

and as I debug the code, I guess the root cause come from this line

Object.setPrototypeOf(requestPrototype, Request.prototype);

if I create a object from it

const req = Object.create(requestPrototype);

console.log(req)

it throws error

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions