Skip to content

Fix/chainhook write queue#269

Merged
Mosas2000 merged 31 commits intomainfrom
fix/chainhook-write-queue
Mar 14, 2026
Merged

Fix/chainhook write queue#269
Mosas2000 merged 31 commits intomainfrom
fix/chainhook-write-queue

Conversation

@Mosas2000
Copy link
Copy Markdown
Owner

Closes #241

Initialize a promise chain that will be used to serialize all
read-modify-write operations on the events file. This prevents
the race condition where concurrent webhook deliveries could
overwrite each other's data.

Refs #241
withEventLock chains the provided function onto the write queue,
ensuring only one read-modify-write cycle runs at a time. The
second argument to .then() ensures the queue continues even if
a previous operation fails.
The read-modify-write cycle (loadEvents -> push -> saveEvents) is
now serialized through the write queue. Concurrent webhook
deliveries will execute their file operations one at a time,
preventing the second write from overwriting events added by the
first.

Closes #241
Previously the catch argument (fn) would re-run the operation on
failure. Now errors are logged and the queue continues.
@Mosas2000 Mosas2000 merged commit 8b2bd9c into main Mar 14, 2026
3 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chainhook file-based event storage has race conditions under concurrent writes

1 participant