Conversation
Member
|
hello @latent-9 thank you for your contribution some test is failing please fix the formatting. |
Author
|
@kevincodex1 Thanks for taking a look. That failure was Biome's import sorting on the new test file: the named imports in tests/lock.test.ts were not alphabetical, so biome ci bailed before the tests ran. I sorted them and re-ran the checks locally, biome ci is clean, type-check passes, and all 61 tests pass. Pushed the fix. |
withLock stores prev.then(() => next) in the lock table but the cleanup compared locks.get(key) against next. The map never holds next (it holds the promise returned by .then), so the tail check was always false and the entry was never deleted. The table grew by one entry per distinct key for the process lifetime, including keys whose critical section threw (the finally still ran the dead check), so the write path leaked entries even for rejected requests. Compare against the chained promise that is actually stored. Adds a test covering serialization, drain-to-empty across many keys and under contention, and cleanup on throw.
latent-9
force-pushed
the
fix/lock-table-leak
branch
from
August 15, 2026 06:18
133b30a to
369079b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
withLock stores prev.then(() => next) in the locks table, but the cleanup compares locks.get(key) against next. The map never holds next (it holds the promise returned by .then), so the tail check is always false and the entry is never deleted. The comment says avoid unbounded growth, but the cleanup is dead: locks grows by one entry per distinct key for the process lifetime. The write path takes a keyed lock per namespace and per owner, and the section can throw before the map is trimmed, so entries leak even for rejected requests. Reachable from PUT/DELETE /api/memory/:ns via upsert. Fix: compare against the chained promise that is actually stored. Adds tests for serialization, drain-to-empty across many keys and under contention, and cleanup on throw; the drain and throw cases fail on the old code and pass with the fix. Full suite green, 61 tests.