Repository navigation
fix(core): find the git root of ES module benchmarks from their file - #129
Conversation
Merging this PR will degrade performance by 14.13%5 warnings, 1 note
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
[Medium impact] The PR appears safe to merge. SummaryConverts ES module file URLs before finding the benchmark's Git root.
Reviews (1) · Last reviewed commit: "fix(core): find the git root of ES modul..." · Reviewed by Greptile |
getCallingFile passed the stack trace file name to getGitDir as is. For ES modules, that name is a file:// URL, which path.resolve treats as a relative path under the current directory. The lookup then found the repository of the current directory instead of the one of the benchmark file: - run from another repository, the URI started with `../`, which breaks the benchmark page and the flame graph - run from a directory outside any repository, it threw "Could not find a git repository" The URL is now converted to a path before the lookup, so ES modules behave like CommonJS and the Vitest plugin. URIs of ES module benchmarks change when the benchmark file is in another repository than the current directory, including a submodule or nested repository run from the outer one. Refs COD-4223 Co-Authored-By: Claude <noreply@anthropic.com>
373bd5d to
dc28e18
Compare
Converts the
file://URL of an ES module benchmark to a path before looking up its git repository, so the URI is relative to the repository that contains the benchmark file.getCallingFilepassed the stack trace file name togetGitDiras is. For ES modules, that name is afile://URL, whichpath.resolvetreats as a relative path under the current directory. The lookup then found the repository of the current directory instead of the one of the benchmark file:../. A URL parser resolves these segments, so the benchmark page 404s and the flame graph can't be stored or downloaded.CommonJS benchmarks and the Vitest plugin already looked up the repository from the benchmark file; ES modules now do the same.
URI change: ES module benchmarks get a new URI, so their history restarts, when the benchmark file is in another repository than the current directory. This includes a file in a submodule or nested repository, run from the outer repository: its URI is now relative to the inner repository. A changelog note for 7.0 should mention it.
getGitRelativePathis exported from@codspeed/core, asutils.tsis re-exported as a whole, so the tests can call it without a stack trace.Refs COD-4223: the issue also covers fixes in other integrations and in the CodSpeed app, so it stays open.