Skip to content

fix: denylist reload now removes stale entries and closes file handles#1895

Open
LautaroPetaccio wants to merge 5 commits into
mainfrom
fix/denylist-reload-and-cleanup
Open

fix: denylist reload now removes stale entries and closes file handles#1895
LautaroPetaccio wants to merge 5 commits into
mainfrom
fix/denylist-reload-and-cleanup

Conversation

@LautaroPetaccio

Copy link
Copy Markdown
Contributor

Summary

Two issues in the denylist reload mechanism:

  • Stale entries never removed (ports/denylist.ts): loadDenylists() only added to the deniedContentIdentifiers Set, never cleared it. If a content hash was removed from the denylist file or remote URL, it remained denied until the server restarted. The fix builds a new Set during each reload cycle and swaps it in atomically after all sources load successfully. If loading fails (outer try/catch), the old set is preserved to avoid briefly un-denying everything.

  • Readline interface never closed: The createInterface() call created a readline wrapper around the file read stream but never closed it after processing. Since loadDenylists() runs every 2 minutes, this leaked a file descriptor each cycle. Added lines.close() after processing.

Also fixes the NodeJS.Timer type to ReturnType<typeof setInterval> to resolve a TS2769 error with clearInterval.

Test plan

  • Denylist tests pass: cd content && npx jest test/unit/ports/denylist.spec.ts --no-coverage
  • Verify removing an entry from the denylist file takes effect after reload

LautaroPetaccio and others added 5 commits April 12, 2026 22:22
loadDenylists() only added to the deniedContentIdentifiers Set and never
cleared it, so entries removed from the denylist file or URL remained
denied until server restart. The fix builds a new Set during reload and
swaps it atomically after all sources load successfully, preserving the
old set if loading fails.

The readline interface created from createInterface() was also never
closed after processing, leaking a file descriptor every reload cycle.

Also fixes the NodeJS.Timer type to use ReturnType<typeof setInterval>
to resolve the TS2769 error with clearInterval.
- Use the already-trimmed cid variable instead of re-trimming the
  original line
- Add test verifying that entries removed from the denylist file are
  no longer reported as denylisted after reload
…land/catalyst into fix/denylist-reload-and-cleanup
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.

1 participant