Files don't update in editor after writing?
kataiki (4)

I'm using Nodejs, and I'm doing a bit of reading/writing to files using fs.writeFileSync and fs.readFileSync.

Writing a file the first time is fine. Writing it the second time, the file in the editor doesn't update. It contains the old data. However, reading it back in using Nodejs, the contents of the file are as expected.

Is there a way to force the editor to display the file properly?

Here's a snip of what I'm talking about

The code will read and output the correct results every 5 seconds, but the file in the editor won't update. This causes some major problems with data integrity. I'm trying to store an accurate log of events, and that doesn't appear to be possible on

You are viewing a single comment. View All
Answered by eankeen (2257) [earned 5 cycles]
View Answer
kataiki (4)

@Pythonier It's not that it's slow. It's that it never gets updated at all. If I refresh the window, the whole program loses the data. It reverts to whatever I last saw when I clicked on the document. It's more apparent with this code, where I print the contents of the file BEFORE writing it.

This is the output I get:

I hit F5 and run it again, and this is the output I get

I lost whatever I wrote onto the file. It's definitely an intermittent problem, and I was able to replicate it with the above output. It's hard to know if my data is safe.