Skip to content

BUG: RouterProvider + createMemoryRouter crashes after navigation in Bun standalone executable #1207

Description

@Samrat-14

Environment

  • Bun: 1.3.14
  • React: 19.x
  • React Router: 8.0.0
  • @opentui/core: 0.4.1
  • @opentui/react: 0.4.1
  • OS: Windows

Description

When running the application using bun run, everything works as expected.

However, after compiling the application into a standalone executable using:

bun build --compile src/index.tsx --outfile dist/my-app

the application crashes whenever navigation occurs using a Data Router created with createMemoryRouter.

The crash happens immediately after calling:

navigate("/foo");

The destination route does not need to exist. The same crash occurs even if /foo is not defined.

The stack trace ends with:

Error: Text must be created inside of a text node
    at createTextInstance
    ...

What I've verified

  • Initial application render works.
  • OpenTUI components (Box, Text, ScrollBox) render correctly.
  • useState-based page switching works correctly.
  • navigate("/") does not crash.
  • navigate("/foo") crashes.
  • Removing the destination component does not change the behavior.
  • The crash only occurs in the compiled executable.
  • The same application works correctly with bun run and bun link.

Additional finding

Replacing the Data Router:

const router = createMemoryRouter(...);

<RouterProvider router={router} />

with the classic router:

<MemoryRouter>
    <Routes>...</Routes>
</MemoryRouter>

completely resolves the issue.

Navigation works correctly in both development and the compiled executable.

Expected behavior

Navigation using createMemoryRouter should work identically in both bun run and a Bun standalone executable.

Actual behavior

Any navigation away from the current route causes the standalone executable to crash with:

Error: Text must be created inside of a text node

while the same code works correctly in development.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions