The file length read by node.js fs.stat is 0

  node.js, question

Google searched for a circle and did not find the answer. First, it posted the code:

const fs = require('fs')'./test.log', {}, (e) => {
 const stats = fs.statSync('./test.log')

When you keep adding text to the test.log file, you will type 0 before typing the actual file length, as shown below

Does anyone know why? Please explain! !

To add:
After running the code, I opened the test.log file with the editor and manually wrote something into it. Does this have any effect?

Print information when changes occur, and have a look.
Look at what the editor does to the file, accessing/modifying the file will trigger a file change event.
Node writes the file and then monitors the file. There is no problem as you said. The following code:

var fs = require('fs');
 var util=require('util');'./test.log', {}, function(e){
 var stats = fs.statSync('./test.log');
 console.log(util.inspect(stats));  //Print information when changes occur
 var writeStream=fs.createWriteStream('./test.log', {
 Flags: 'a plus',
 defaultEncoding: 'utf8'