Repository navigation
fix: cap dumped filename length to avoid ENAMETOOLONG - #19
Open
johnhldiver-beep wants to merge 1 commit into
Open
johnhldiver-beep wants to merge 1 commit into
johnhldiver-beep wants to merge 1 commit into
Conversation
Truncate the sanitized id prefix in Debugger.encodeId so the resulting dump filename (prefix + '-' + hash + '.js') stays within filesystem limits (~200 bytes). The deterministic hashCode suffix is kept so distinct long ids that truncate to the same prefix still map to different files. Short ids are unchanged. Ref: vitest-dev/vitest#7744
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Debugger.encodeIdinsrc/debug.tsbuilt dump filenames from the full sanitized module id with no length cap, so a very long id crashed withENAMETOOLONGwhen writing under.vite-node/dump(reported as vitest-dev/vitest#7744, where a long test-file path produced a filename like_Volumes_..._very_..._long_spec_tsx--51554923.js).The fix caps the filename at 200 bytes: a new
MAX_DUMP_FILE_NAME_LENGTH = 200constant; names that fit are returned unchanged, otherwise the sanitized prefix is sliced soprefix + '-' + hash + '.js'is exactly 200 bytes. The deterministichashCode(id)suffix is kept, so distinct long ids still map to different files. The sanitized alphabet ([\w@-]) is ASCII-only, so bytes === chars, and negative hashes (e.g.-1252568592, the double dash in the reported filename) are handled by the length math. Short ids are byte-identical to before.Note: Vitest 4 no longer depends on vite-node (it moved to Vite's Module Runner), so this fix is for vite-node itself and its other consumers; the reported crash came through Vitest's
server.debug.dumpwhen it still used vite-node.Verification
test/test/debug.test.ts(4 tests): long-id length cap (byteLength ≤ 200 and < 255);dumpFile/loadDumpround-trip with a very long id; two distinct long ids sharing a 400-char prefix produce different filenames, both within limits; three short ids encode byte-identical to the pre-fix formula (hashes independently recomputed).tsc --noEmit) exits 0; lint on both changed files exits 0; build (pnpm run build) succeeds.Ref vitest-dev/vitest#7744