Skip to content

Bun crash when .env file contains any content (ThreadLock panic) #15127

Closed

Description

@Shabba-D

Description

opencode crashes immediately on startup when the working directory contains a .env file with any content. An empty .env file does not trigger the crash.
Steps to reproduce:

Create a .env file in the working directory with any content, even a single line like WP_BASE_URL=localhost
Run opencode from that directory
opencode crashes immediately

Expected behavior: opencode starts normally and reads the .env file.
Workaround: Removing or emptying the .env file prevents the crash.
Error output:
Bun v1.3.10-canary.100 (6b1d6c76) Windows x64 (baseline)
panic(thread 24096): Internal assertion failure: ThreadLock is locked by thread 22284, not thread 24096
oh no: Bun has crashed. This indicates a bug in Bun, not your code.
Additional notes:

The crash occurs regardless of the content of the .env file (tested with URLs, plain strings, special characters)
The crash does not occur when running opencode from a directory without a .env file
The issue is specific to the bundled Bun canary version — system Bun is stable and unaffected

Plugins

No response

OpenCode version

1.2.14

Steps to reproduce

No response

Screenshot and/or share link

Bun Canary v1.3.10-canary.100 (6b1d6c76) Windows x64 (baseline)
Windows v.win11_dt
CPU: sse42 avx avx2
Args: "C:\Users\detre\AppData\Roaming\npm\node_modules\opencode-ai\node_modules\opencode-windows-x64\bin\opencode.exe" "--user-agent=opencode/1.2.14" "--use-system-ca" "--"
Features: Bun.stderr(2) Bun.stdin(2) Bun.stdout(2) fetch(2) jsc standalone_executable workers_spawned
Builtins: "bun:ffi" "bun:main" "bun:sqlite" "node:assert" "node:async_hooks" "node:buffer" "node:child_process" "node:console" "node:crypto" "node:dns" "node:events" "node:fs" "node:fs/promises" "node:http" "node:https" "node:module" "node:net" "node:os" "node:path" "node:process" "node:querystring" "node:readline" "node:stream" "node:stream/consumers" "node:stream/promises" "node:string_decoder" "node:timers" "node:timers/promises" "node:tls" "node:tty" "node:url" "node:util" "undici" "node:v8" "node:http2" "node:diagnostics_channel" "node:dgram"
Elapsed: 1290ms | User: 1390ms | Sys: 312ms
RSS: 0.52GB | Peak: 0.52GB | Commit: 0.86GB | Faults: 136672 | Machine: 33.76GB

panic(thread 15748): Internal assertion failure: ThreadLock is locked by thread 25004, not thread 15748
oh no: Bun has crashed. This indicates a bug in Bun, not your code.

Operating System

No response

Terminal

No response

Activity

  1. github-actions commented on Feb 25, 2026

    @github-actions
    Contributor

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

    These issues all describe the same root cause: the bundled Bun canary version loading the project's .env file and triggering a ThreadLock panic on startup.

  2. letruxux commented on Feb 25, 2026

    @letruxux

    can confirm i have the same issue

  3. HaydenDekker commented on Feb 25, 2026

    @HaydenDekker

    can confirm experiencing the same issue to.

  4. sebysebyseby commented on Feb 26, 2026

    @sebysebyseby

    Same issue here. I've noticed that cd'ing into a subdirectory and running opencode from there works though even if there is content in the .env file.

  5. ChrisColeTech commented on Feb 26, 2026

    @ChrisColeTech

    What a bizarre bug.

    Thank you for the solution

  6. Hona commented on Feb 26, 2026

    @Hona
    Member

    It's a bug with Bun. I've submitted an issue and PR. I'm working with their team to get it out asap. Thanks everyone.

    Specifically if there is a .env in your startup directory it will crash.

  7. Hona commented on Feb 26, 2026

    @Hona
    Member

    please upgrade to latest OpenCode v1.2.15 - and try again.

    There should be no more segfaults/crashes.

    Can you confirm it works fine after the version is >v1.2.15 :)

  8. Shabba-D commented on Feb 26, 2026

    @Shabba-D
    Author

    Yes, it works fine now.

    Thank you for the quick response.

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingwindows

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions