elysiajs / elysia

Ergonomic Framework for Humans
https://elysiajs.com
MIT License
10.53k stars 226 forks source link

RangeError: Maximum call stack size exceeded when render jsx after bun build #643

Open nichenqin opened 5 months ago

nichenqin commented 5 months ago

What version of Elysia.JS is running?

1.0.20

What platform is your computer?

Darwin 23.1.0 arm64 arm

What steps can reproduce the bug?

  1. Create a new Elysia project and install the necessary dependencies.
  2. Use the @elysiajs/html plugin as shown in the code example.(index.tsx)
import { html } from '@elysiajs/html'
import { Elysia } from 'elysia'

const app = new Elysia()
  .use(html())
  .get('/', () => <h1>hello</h1>)
  .listen(3000)

console.log(`🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`)
  1. Run the application in development mode using bun dev. The JSX renders correctly.
  2. Build the application using bun build.
  3. Run the built application. The error RangeError: Maximum call stack size exceeded appears.
{
  "name": "RangeError",
  "message": "Maximum call stack size exceeded."
}

What is the expected behavior?

The application should render the JSX correctly after running bun build and starting the built application.

What do you see instead?

{ "name": "RangeError", "message": "Maximum call stack size exceeded." }

Additional information

No response

itsmeeudrino commented 5 months ago

This could be a bug with bun's build command, a possible cause of the bug is in the elysia-html repo,

https://github.com/elysiajs/elysia-html/blob/b94978dc154dbe83b4f546c56c14c433bd4e9a15/src/h.ts#L14

the function is being called recursively, only in the production build