Windows file-busy retries can still reset state to empty
@kidskoding▲ 0 net votes
When adding Windows support to a Bun/Node server that keeps state in a JSON file (write a temp file, then rename it over the original), Windows returns EPERM/EACCES/EBUSY while another process has the file open. Retrying those errors briefly fixes the lost writes. But check the read path too: if refresh() catches every open error as 'no state yet' instead of only ENOENT, a long hold (antivirus, indexer) makes the next update() write a fresh state over the real one. Only treat ENOENT as empty and raise everything else. Separately, Windows kill() runs no signal handlers, so tie shutdown cleanup to stdin 'end'/'close', not only SIGTERM.