commandkit icon indicating copy to clipboard operation
commandkit copied to clipboard

bug: `commandkit dev` fails with `[UNHANDLEABLE_ERROR] Invalid argument (os error 22)`

Open maybeizen opened this issue 11 months ago • 2 comments

When running the commandkit dev command, the build process fails immediately with an unhandleable error originating from rolldown.

Error/stack:

Build failed: Error: Build failed with 1 error:

[UNHANDLEABLE_ERROR] Error: Something went wrong inside rolldown, please report this problem at https://github.com/rolldown/rolldown/issues.
Invalid argument (os error 22)

    at aggregateBindingErrorsIntoJsError (file:///media/maybeizen/External/projects/archive/netherhost/nethercore_v2/node_modules/rolldown/dist/shared/src-CPA2meNe.mjs:2485:18)
    at unwrapBindingResult (file:///media/maybeizen/External/projects/archive/netherhost/nethercore_v2/node_modules/rolldown/dist/shared/src-CPA2meNe.mjs:2460:128)
    at RolldownBuild.write (file:///media/maybeizen/External/projects/archive/netherhost/nethercore_v2/node_modules/rolldown/dist/shared/src-CPA2meNe.mjs:4242:33)
    at async build (file:///media/maybeizen/External/projects/archive/netherhost/nethercore_v2/node_modules/rolldown/dist/shared/src-CPA2meNe.mjs:4275:22)
    at async file:///media/maybeizen/External/projects/archive/netherhost/nethercore_v2/node_modules/tsdown/dist/src-Cy1Bj4rU.mjs:1380:24
    at async Promise.all (index 0)
    at async rebuild (file:///media/maybeizen/External/projects/archive/netherhost/nethercore_v2/node_modules/tsdown/dist/src-Cy1Bj4rU.mjs:1372:3)
    at async buildSingle (file:///media/maybeizen/External/projects/archive/netherhost/nethercore_v2/node_modules/tsdown/dist/src-Cy1Bj4rU.mjs:1360:2)
    at async Promise.all (index 0)
    at async build$1 (file:///media/maybeizen/External/projects/archive/netherhost/nethercore_v2/node_modules/tsdown/dist/src-Cy1Bj4rU.mjs:1329:19) {
  errors: [Getter/Setter]
}

Desktop:

  • OS: Linux Mint 22.2
  • Node Version: v24.12.0
  • Package Manager: Bun v1.3.5
  • CommandKit Version: 1.2.0-rc.11

Additional Notes

  • This project is stored on an external SSD formatted as NTFS.

maybeizen avatar Dec 20 '25 16:12 maybeizen

I can confirm this is an issue with the file system. I've moved the project to an internal SSD (ext4) and it resolved it. This suggests an issue between rolldown's file writing system and NTFS mount behaviors on Linux.

maybeizen avatar Dec 20 '25 17:12 maybeizen

It looks like the failure is happening inside RolldownBuild.write and surfaces as:

[UNHANDLEABLE_ERROR] Invalid argument (os error 22)

This maps to EINVAL, which usually means a low-level filesystem operation is not supported by the underlying filesystem.

Given that moving the project from NTFS to ext4 fixes the issue, this points to a filesystem compatibility problem rather than a logic bug in commandkit or tsdown.

A likely cause is that rolldown is using optimized file writes (most likely writable mmap, possibly also clone/copy syscalls). NTFS on Linux (via ntfs-3g or ntfs3) does not fully support these operations, and the kernel can return EINVAL in those cases. Native filesystems like ext4 don’t have this limitation, which explains why it works there.

Also worth noting: in dev mode, commandkit builds with unbundle: true and sourcemap: true by default, which results in many individual file writes. That increases the chance of hitting this limitation on NTFS.

To confirm the exact failing syscall, running under strace would help:

strace -f -o trace.log commandkit dev

Then check the end of the log for something like mmap, copy_file_range, or ioctl failing with EINVAL.

As for improvements, this probably needs handling in rolldown by falling back to a safe write when these operations fail. On the commandkit side, it could help to detect this case (error contains UNHANDLEABLE_ERROR + os error 22) and show a clearer message suggesting filesystem compatibility as the cause.

As a quick workaround, it might also be worth trying:

export default defineConfig({
  sourceMap: {
    development: false,
  },
});

to reduce the number of file writes.

If needed, I can help analyze a strace log or try to narrow down the exact syscall causing this.

AboMeezO avatar Apr 07 '26 13:04 AboMeezO