Skip to content

Bun bundled application fails to run in browser (reading loadEnv) #479

@chrisui

Description

@chrisui

Describe the bug

When using bun to bundle a browser-client app, if the @openai/realtime-agents package is imported it will simply break at runtime.

frontend TypeError: Cannot read properties of null (reading 'loadEnv')
      at loadEnv3 (/Users/chris/Projects/bun-openai-bug/node_modules/@openai/agents-core/dist/config.mjs:8:12)
      at isEnabled (/Users/chris/Projects/bun-openai-bug/node_modules/@openai/agents-core/dist/config.mjs:17:17)
      at get dontLogModelData (/Users/chris/Projects/bun-openai-bug/node_modules/@openai/agents-core/dist/config.mjs:41:16)
      at /Users/chris/Projects/bun-openai-bug/node_modules/@openai/agents-core/dist/logger.mjs:7:34
    from browser tab http://localhost:3000/

Debug information

  • Agents SDK version: "@openai/agents-realtime": "^0.1.3"
  • Runtime environment: Bun v1.2.22 (Chrome browser)

Repro steps

Repro: https://github.com/chrisui/bun-openai-bug

git clone [email protected]:chrisui/bun-openai-bug.git
bun install
bun index.html

goto localhost:3000 and you'll see the error

Expected behavior

No runtime error.

Compare to it working with bunx vite dev index.html

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions