Skip to content

[Panic]: ctrl+c while watch mode is building (plus some very specific conditions) leads to a reproducible panic #8951

@dumbmatter

Description

@dumbmatter

Panic message

Rolldown panicked. This is a bug in Rolldown, not your code.

thread '<unnamed>' (1526031) panicked at /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/napi-3.8.3/src/threadsafe_function.rs:831:5:
assertion `left == right` failed
  left: 10
 right: 0
stack backtrace:
   0:     0x745ae18e9982 - <unknown>
   1:     0x745ae18fc977 - <unknown>
   2:     0x745ae18c4016 - <unknown>
   3:     0x745ae18d0a16 - <unknown>
   4:     0x745ae18d0876 - <unknown>
   5:     0x745ae0b196ae - <unknown>
   6:     0x745ae18d0c92 - <unknown>
   7:     0x745ae18d0ad8 - <unknown>
   8:     0x745ae18cb0d9 - <unknown>
   9:     0x745ae18b7b3d - <unknown>
  10:     0x745ae09c428c - <unknown>
  11:     0x745ae09c41a3 - <unknown>
  12:     0x745ae09c29e2 - <unknown>
  13:     0x745ae173be00 - <unknown>
  14:     0x745ae0c927d4 - <unknown>
  15:           0x8555d1 - _ZN6v8impl12_GLOBAL__N_118ThreadSafeFunction7AsyncCbEP10uv_async_s
  16:          0x1933203 - uv__async_io
                               at /home/iojs/build/ws/out/../deps/uv/src/unix/async.c:208:5
  17:          0x1949caa - uv__io_poll
                               at /home/iojs/build/ws/out/../deps/uv/src/unix/linux.c:1565:11
  18:          0x1933ec7 - uv_run
                               at /home/iojs/build/ws/out/../deps/uv/src/unix/core.c:460:5
  19:           0x78a155 - _ZN4node21SpinEventLoopInternalEPNS_11EnvironmentE
  20:           0xa29061 - _ZN4node6worker6Worker3RunEv
  21:           0xa291d6 - _ZZN4node6worker6Worker11StartThreadERKN2v820FunctionCallbackInfoINS2_5ValueEEEENUlPvE_4_FUNES8_
  22:     0x745b20e9caa4 - start_thread
                               at ./nptl/pthread_create.c:447:8
  23:     0x745b20f29c6c - clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
  24:                0x0 - <unknown>

Please report this issue at: https://github.com/rolldown/rolldown/issues/new?template=panic_report.yml
fatal runtime error: failed to initiate panic, error 5, aborting
Aborted (core dumped)

Reproduction

On the rolldown-panic branch of this repo https://github.com/zengm-games/zengm/tree/rolldown-panic run this command:

$ node tools/watch/watchJs.ts

When it prints "Press ctrl+c now to see panic" (which happens after it calls watch) if I press ctrl+c I get a panic 100% of the time.

If you wait a bit longer it says "Too late!" - this is when the initial build from watch has completed, and then if you press ctrl+c there is no panic.

I made this as minimal as I could, but I couldn't fully isolate it because the panic goes away if I change many of these little details in watchJs.ts and watchJsWorker.ts such as:

  • deleting the unused node:fs/promises import
  • deleting the empty external function in the rolldown config
  • deleting the sportFunctions rolldown plugin, which runs a custom babel plugin on some files
  • deleting the exitHandler function
  • making it run in the main thread rather than using node:worker_threads

System Info

System:
    OS: Linux 6.8 Ubuntu 24.04.4 LTS 24.04.4 LTS (Noble Numbat)
    CPU: (8) x64 Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz
    Memory: 9.16 GB / 31.13 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 24.14.0 - /usr/bin/node
    Yarn: 1.22.22 - /usr/bin/yarn
    npm: 11.9.0 - /usr/bin/npm
    pnpm: 10.32.1 - /home/user/.local/share/pnpm/pnpm
  Browsers:
    Brave Browser: 146.1.88.130
    Chrome: 146.0.7680.80
    Firefox: 149.0
    Firefox Developer Edition: 149.0
  npmPackages:
    rolldown: 1.0.0-rc.12 => 1.0.0-rc.12

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions