Summary
A race condition exists in the localfilesystem context store that can cause data loss during Node-RED shutdown.
Problem
When close() is called on the localfilesystem context store, pending writes may be lost because:
close() clears the pending write timeout
- New
set() calls can still schedule new timeouts after close() starts
- The final
_flushPendingWrites() may not include all pending data
Severity
HIGH - Can cause silent data loss of context values during shutdown or restart.
Proposed Fix
- Add a
closing flag that is set at the start of close()
- Check this flag in
set() to prevent scheduling new timeouts during shutdown
- Always flush pending writes in
close() regardless of timeout state
Environment
- Node-RED version: 4.x
- Affects: Any deployment using file-based context storage