Skip to content

Bundled binary crashes with TypeError on namespace re-exports #18525

Closed as not planned

Description

@sjawhar

Bug description

The Bun-bundled binary crashes at startup with errors like:

TypeError: undefined is not an object (evaluating 'Snapshot2.FileDiff.array')
TypeError: undefined is not an object (evaluating 'ProviderAuth2.Authorization.optional')

Root cause

Nine facade files (e.g. src/snapshot/index.ts, src/provider/auth.ts) re-export values from a service module inside a TypeScript namespace:

import { Snapshot as S } from "./service"
export namespace Snapshot {
  export const FileDiff = S.FileDiff
}

Bun's bundler transpiles this into self-referential assignments (Snapshot.FileDiff = Snapshot.FileDiff). When circular imports delay module initialization, the right-hand side is undefined.

Steps to reproduce

  1. Introduce any circular dependency chain that passes through one of these facade modules
  2. Build with bun run build --single
  3. Run the binary — crashes before startup completes

Expected behavior

Binary starts without TypeError.

Environment

  • Bun 1.3.10
  • opencode built with --single flag

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 21, 2026
  2. github-actions commented on Mar 21, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of an existing issue. Please check:

    Please check whether #18451 already covers your case. If so, it may be best to add any new details there.

  3. assigned and unassigned on Apr 26, 2026
  4. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  5. github-actions commented on Jul 4, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions