Skip to content

Commit

Permalink
fix: fsync: false when writing cache files (#9695)
Browse files Browse the repository at this point in the history
  • Loading branch information
FauxFaux authored Mar 24, 2020
1 parent 4a59daa commit 2c666c2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion packages/jest-transform/src/ScriptTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ describe('ScriptTransformer', () => {
expect(writeFileAtomic.sync).toBeCalledTimes(2);
expect(writeFileAtomic.sync).toBeCalledWith(result.sourceMapPath, mapStr, {
encoding: 'utf8',
fsync: false,
});
});

Expand Down Expand Up @@ -438,7 +439,7 @@ describe('ScriptTransformer', () => {
expect(writeFileAtomic.sync).toBeCalledWith(
result.sourceMapPath,
sourceMap,
{encoding: 'utf8'},
{encoding: 'utf8', fsync: false},
);
});

Expand Down Expand Up @@ -507,6 +508,7 @@ describe('ScriptTransformer', () => {
JSON.stringify(map),
{
encoding: 'utf8',
fsync: false,
},
);
});
Expand Down Expand Up @@ -574,6 +576,7 @@ describe('ScriptTransformer', () => {
JSON.stringify(instrumentedCodeMap),
{
encoding: 'utf8',
fsync: false,
},
);

Expand Down Expand Up @@ -614,6 +617,7 @@ describe('ScriptTransformer', () => {
JSON.stringify(instrumentedCodeMap),
{
encoding: 'utf8',
fsync: false,
},
);

Expand Down

0 comments on commit 2c666c2

Please sign in to comment.