Skip to content

[Bug]: an asset file name with [hash:23] panics rolldown #4016

@blixt

Description

@blixt

Reproduction link or steps

Set output.assetFileNames to "[hash:23].[ext]"

What is expected?

Based on the unit tests and behaviors I could find output.chunkFileNames will limit the hash length to 21 characters even if requesting more. While for assets, you can request 22 and get 22, a behavior that's possibly even more buggy than the panic.

What is actually happening?

For [hash:22], a 22-character hash is created (which is not possible for chunk filenames). For [hash:23] rolldown panics:

thread '<unnamed>' panicked at crates/rolldown_common/src/file_emitter.rs:190:40:
byte index 23 is out of bounds of `BKe-RU-cO4wpXAsrT9DUL7`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 772515008
error: script "build" was terminated by signal SIGABRT (Abort)
Aborted

System Info

System:
    OS: Linux 6.10 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (16) arm64 unknown
    Memory: 26.79 GB / 31.29 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 20.19.0 - /usr/local/share/nvm/versions/node/v20.19.0/bin/node
    Yarn: 1.22.22 - /usr/bin/yarn
    npm: 10.8.2 - /usr/local/share/nvm/versions/node/v20.19.0/bin/npm
    pnpm: 10.7.0 - /usr/local/share/nvm/versions/node/v20.19.0/bin/pnpm
    bun: 1.2.6 - /usr/local/bin/bun

Any additional comments?

No response

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions