Skip to content

Segfault when calling Bun.secrets inside AsyncLocalStorage.run() #24711

Closed

Description

@monostop

How can we reproduce the crash?

Hi,

Bun.secrets crashes with a segmentation fault when called from within an AsyncLocalStorage context.

The following is my environment:
Bun v1.3.2 - b131639
macOS v15.6.1

And the following is a minimal reproduction.

import { AsyncLocalStorage } from "async_hooks"

const storage = new AsyncLocalStorage<{ context: string }>()

await storage.run({ context: "test" }, async () => {
  await Bun.secrets.set({
    service: "test-service",
    name: "test-account",
    value: "test-data",
  })
})

Note

  • Bun.secrets works fine when called outside AsyncLocalStorage
  • This blocks OAuth flows that need to save credentials within async context managers

Relevant log output

bun minimal-crash-test.ts 
============================================================
Bun v1.3.2 (b131639c) macOS Silicon
macOS v15.6.1
CPU: fp aes crc32 atomics
Args: "bun" "minimal-crash-test.ts"
Features: Bun.stderr(2) Bun.stdout(2) bunfig jsc transpiler_cache(9) tsconfig(4) tsconfig_paths(3) 
Builtins: "bun:main" "node:assert" "node:async_hooks" "node:fs" "node:module" "node:os" "node:path" "node:tty" "node:util" 
Elapsed: 287ms | User: 99ms | Sys: 55ms
RSS: 88.03MB | Peak: 88.03MB | Commit: 1.07GB | Faults: 1510 | Machine: 25.77GB

panic(main thread): Segmentation fault at address 0x1A
oh no: Bun has crashed. This indicates a bug in Bun, not your code.

Stack Trace (bun.report)

Bun v1.3.2 (b131639) on macos aarch64 [AutoCommand]

Segmentation fault at address 0x0000001A

Features: transpiler_cache, tsconfig, tsconfig_paths, Bun.stderr, Bun.stdout, bunfig, jsc

Activity

  1. github-actions commented on Nov 14, 2025

    @github-actions
    Contributor

    Thank you for reporting this crash.

    For Bun's internal tracking, this issue is BUN-121G.

  2. github-actions commented on Nov 14, 2025

    @github-actions
    Contributor

    Found 3 possible duplicate issues:

    1. Bun.secrets.get not working on linux fedora 42 : panic: Segmentation fault at address 0x26978C0 #22190
    2. Bun.secrets crash on WSL2/Ubuntu (1.2.22-canary) #22246
    3. Bun.serve crash with request context run in AsyncLocalStorage #10846

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  3. monostop commented on Nov 14, 2025

    @monostop
    Author

    It seems related to #10846 still occurring (at least on macOS). This crash happens only when executing Bun.secrets.set inside AsyncLocalStorage context.

  4. added a commit that references this issue on Nov 23, 2025
    b6e9887
  5. added a commit that references this issue on Nov 23, 2025
    3c60fcd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashAn issue that could cause a crashmacOSAn issue that occurs on macOSneeds triageruntime

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions