From 2c666c21c6efc1fcadaf820cc9b47bf0ac10505a Mon Sep 17 00:00:00 2001 From: Chris West Date: Tue, 24 Mar 2020 08:57:16 +0000 Subject: [PATCH] fix: fsync: false when writing cache files (#9695) --- CHANGELOG.md | 1 + packages/jest-transform/src/ScriptTransformer.ts | 2 +- .../jest-transform/src/__tests__/script_transformer.test.js | 6 +++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 169c2270b0f7..56f61ede0f5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - `[jest-haste-map]` [**BREAKING**] Remove `mapper` option ([#9581](https://github.com/facebook/jest/pull/9581)) - `[*]` Support array of paths for `moduleNameMapper` aliases ([#9465](https://github.com/facebook/jest/pull/9465)) - `[jest-reporters]` Adds ability to pass options to the istanbul-reporter through `coverageReporters` ([#9572](https://github.com/facebook/jest/pull/9572)) +- `[jest-transform]` `writeCacheFile` no longer calls `fsync` ([#9695](https://github.com/facebook/jest/pull/9695)) ### Fixes diff --git a/packages/jest-transform/src/ScriptTransformer.ts b/packages/jest-transform/src/ScriptTransformer.ts index ccd18834aa42..a3658842f164 100644 --- a/packages/jest-transform/src/ScriptTransformer.ts +++ b/packages/jest-transform/src/ScriptTransformer.ts @@ -630,7 +630,7 @@ function readCodeCacheFile(cachePath: Config.Path): string | null { */ const writeCacheFile = (cachePath: Config.Path, fileData: string) => { try { - writeFileAtomic(cachePath, fileData, {encoding: 'utf8'}); + writeFileAtomic(cachePath, fileData, {encoding: 'utf8', fsync: false}); } catch (e) { if (cacheWriteErrorSafeToIgnore(e, cachePath)) { return; diff --git a/packages/jest-transform/src/__tests__/script_transformer.test.js b/packages/jest-transform/src/__tests__/script_transformer.test.js index 63dd80a9d08b..596116eb3441 100644 --- a/packages/jest-transform/src/__tests__/script_transformer.test.js +++ b/packages/jest-transform/src/__tests__/script_transformer.test.js @@ -407,6 +407,7 @@ describe('ScriptTransformer', () => { expect(writeFileAtomic.sync).toBeCalledTimes(2); expect(writeFileAtomic.sync).toBeCalledWith(result.sourceMapPath, mapStr, { encoding: 'utf8', + fsync: false, }); }); @@ -438,7 +439,7 @@ describe('ScriptTransformer', () => { expect(writeFileAtomic.sync).toBeCalledWith( result.sourceMapPath, sourceMap, - {encoding: 'utf8'}, + {encoding: 'utf8', fsync: false}, ); }); @@ -507,6 +508,7 @@ describe('ScriptTransformer', () => { JSON.stringify(map), { encoding: 'utf8', + fsync: false, }, ); }); @@ -574,6 +576,7 @@ describe('ScriptTransformer', () => { JSON.stringify(instrumentedCodeMap), { encoding: 'utf8', + fsync: false, }, ); @@ -614,6 +617,7 @@ describe('ScriptTransformer', () => { JSON.stringify(instrumentedCodeMap), { encoding: 'utf8', + fsync: false, }, );