nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
105.49k stars 28.61k forks source link

Nodejs process crashed when using `console` to print some object. TypeError: Cannot read properties of undefined (reading 'reloadNavigation') #52887

Open zyh825 opened 2 months ago

zyh825 commented 2 months ago

Version

v20.13.0

Platform

Darwin zhangyuhangdeMacBook-Pro.local 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:19:22 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8112 arm64

Subsystem

No response

What steps will reproduce the bug?

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

import { polyfillHandler } from './polyfill-handler.js';

const app = new Hono();

app.get('*', async (c) => {
  // console.log(c.env); // ok
  // console.log(c.res); // ok
  // console.log(c.req); // crashed here !!!!!
  // console.log(c.req.header('User-Agent')); // ok
  // console.log(c.req.path); // ok
  // console.log(c.req.url); // ok

  if (/\/polyfill(\.min)?\.js$/.test(c.req.path)) {
    return polyfillHandler(c);
  }
  c.res.headers.set(
    'Cache-Control',
    'public, s-maxage=31536000, max-age=604800, stale-while-revalidate=604800, stale-if-error=604800, immutable'
  );
  return c.text('Not Found', 404);
});

The reproduce code & some cases is show above。 print a deep value is still work,like c.req.url

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior? Why is that the expected behavior?

No response

What do you see instead?

This is caused by either a bug in Node.js or incorrect usage of Node.js internals. Please open an issue with this stack trace at https://github.com/nodejs/node/issues

at Function.fail (node:internal/assert:20:9)
at handleMaxCallStackSize (node:internal/util/inspect:1556:10)
at formatRaw (node:internal/util/inspect:1062:12)
at formatValue (node:internal/util/inspect:840:10)
at formatProperty (node:internal/util/inspect:1945:11)
at formatRaw (node:internal/util/inspect:1054:9)
at formatValue (node:internal/util/inspect:840:10)
at inspect (node:internal/util/inspect:364:10)
at formatWithOptionsInternal (node:internal/util/inspect:2298:40)
at formatWithOptions (node:internal/util/inspect:2160:10)

Additional information

No response

marco-ippolito commented 2 months ago

Thanks for the report, would you be able to provide a repro without 3rd party dependencies?

zyh825 commented 2 months ago

https://github.com/zyh825/polyfill-service Cause i don't known how this crash work, Here the demo project with 3rd party dependencies. Hope it helps。