Skip to content

Commit 07afae1

Browse files
author
Ben Newman
committed
Revert "Write .meteor-portable-2.json files synchronously."
This reverts commit 4e4e204.
1 parent 6ae1473 commit 07afae1

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

tools/isobuild/meteor-npm.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -528,20 +528,21 @@ const isPortable = Profile("meteorNpm.isPortable", dir => {
528528
isPortable(files.pathJoin(dir, itemName)));
529529

530530
if (canCache) {
531-
try {
532-
files.writeFile(
533-
portableFile,
534-
JSON.stringify(result) + "\n",
535-
"utf8"
536-
);
537-
} catch (ignored) {
538-
// Don't worry if the write fails, e.g. because the file system is
539-
// read-only (#6591). Failing to write the file only means more work
540-
// next time.
541-
}
531+
// Write the .meteor-portable file asynchronously, and don't worry
532+
// if it fails, e.g. because the file system is read-only (#6591).
533+
// Failing to write the file only means more work next time.
534+
fs.writeFile(
535+
portableFile,
536+
JSON.stringify(result) + "\n",
537+
error => {
538+
// Once the asynchronous write finishes (successful or not), we no
539+
// longer need to cache the written value in memory.
540+
delete portableCache[portableFile];
541+
},
542+
);
542543

543-
// Cache the result immediately in memory so we don't have to wait for
544-
// file change notifications to invalidate optimisticReadJsonOrNull.
544+
// Cache the result immediately in memory so that the asynchronous
545+
// write won't confuse synchronous optimisticReadJsonOrNull calls.
545546
portableCache[portableFile] = result;
546547
}
547548

0 commit comments

Comments
 (0)