Skip to content

JSX DOM render extremely slow #3201

@luaVolk

Description

@luaVolk

What version of Hono are you using?

4.5.2

What runtime/platform is your app running on?

Bun

What steps can reproduce the bug?

import { render } from "hono/jsx/dom";

const root = document.getElementById("root");

render(
	<>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
		<div><span></span></div>
	</>
, root);

What is the expected behavior?

Rendering something of that complexity should be immediate

What do you see instead?

It takes about 12 seconds to render the code above. Twice as much if I add one more <div><span></span></div>

Additional information

The time it takes for the render function to complete increases exponentially with the amount of nodes.
From what I gathered it seems to get stuck in the findInsertBefore function

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions