Skip to content

Commit edccbd6

Browse files
committed
fix: fsync: false when writing cache files
We're using writeFileAtomic here in order to get atomic rename, not to get full system power failure resilience. Most(tm) filesystems will guarantee either/or during a crash here, which is plenty enough for us. fsync is a nearly 3x slowdown for me, ts-jest'ing my whole codebase (~900 files in testcase).
1 parent 4a59daa commit edccbd6

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- `[jest-haste-map]` [**BREAKING**] Remove `mapper` option ([#9581](https://github.com/facebook/jest/pull/9581))
88
- `[*]` Support array of paths for `moduleNameMapper` aliases ([#9465](https://github.com/facebook/jest/pull/9465))
99
- `[jest-reporters]` Adds ability to pass options to the istanbul-reporter through `coverageReporters` ([#9572](https://github.com/facebook/jest/pull/9572))
10+
- `[jest-transform]` `writeCacheFile` no longer calls `fsync` ([#9695](https://github.com/facebook/jest/pull/9695))
1011

1112
### Fixes
1213

packages/jest-transform/src/ScriptTransformer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ function readCodeCacheFile(cachePath: Config.Path): string | null {
630630
*/
631631
const writeCacheFile = (cachePath: Config.Path, fileData: string) => {
632632
try {
633-
writeFileAtomic(cachePath, fileData, {encoding: 'utf8'});
633+
writeFileAtomic(cachePath, fileData, {encoding: 'utf8', fsync: false});
634634
} catch (e) {
635635
if (cacheWriteErrorSafeToIgnore(e, cachePath)) {
636636
return;

0 commit comments

Comments
 (0)