Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
Closed
Labels
moduleIssues and PRs related to the module subsystem.Issues and PRs related to the module subsystem.
Description
- Version: 15.5.0
- Platform: Windows 10 x64
- Subsystem: fs, cjs modules
What steps will reproduce the bug?
It seems there may be some race conditions.
Error (cannot find module...):
constfs=require('fs');try{require('./test.json');}catch(err){}fs.writeFileSync('test.json','[]');console.log(require('./test.json'));With timeout — OK:
constfs=require('fs');try{require('./test.json');}catch(err){}fs.writeFileSync('test.json','[]');setTimeout(()=>{console.log(require('./test.json'));},1000);With callback — OK:
constfs=require('fs');try{require('./test.json');}catch(err){}fs.writeFile('test.json','[]',()=>{console.log(require('./test.json'));});Promisified — OK:
constfs=require('fs/promises');try{require('./test.json');}catch(err){}(asyncfunction(path){awaitfs.writeFile('test.json','[]');console.log(require('./test.json'));})();Without failed try — OK:
constfs=require('fs');fs.writeFileSync('test.json','[]');console.log(require('./test.json'));Previously reported in nodejs/help#3144
Metadata
Metadata
Assignees
Labels
moduleIssues and PRs related to the module subsystem.Issues and PRs related to the module subsystem.