Skip to content

Race condition in localfilesystem context store during shutdown #5450

@Dennis-SEG

Description

@Dennis-SEG

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:

  1. close() clears the pending write timeout
  2. New set() calls can still schedule new timeouts after close() starts
  3. 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

  1. Add a closing flag that is set at the start of close()
  2. Check this flag in set() to prevent scheduling new timeouts during shutdown
  3. Always flush pending writes in close() regardless of timeout state

Environment

  • Node-RED version: 4.x
  • Affects: Any deployment using file-based context storage

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions