File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -528,20 +528,21 @@ const isPortable = Profile("meteorNpm.isPortable", dir => {
528
528
isPortable ( files . pathJoin ( dir , itemName ) ) ) ;
529
529
530
530
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
+ ) ;
542
543
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 .
545
546
portableCache [ portableFile ] = result ;
546
547
}
547
548
You can’t perform that action at this time.
0 commit comments