You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(nip56): start the hidden-content cache on every worker - #1241
The cache already reads the settings on every tick and queries the database only while hideActionableReports is on, so it was built to pick up a later change. The boot condition defeated that: a worker that booted with reporting off never started the timer.
the cache now starts on every worker, whatever nip56.enabled says at boot;
nothing changes in hidden-content-cache.ts: each tick still checks hideActionableReports first, so a relay that does not use reporting reads the settings object every 30 seconds and never queries the database;
the comment in worker-factory.ts says why the start is unconditional.
Related Issue
Partly addresses #1022 (F-032). The other findings in that issue are handled separately.
Motivation and Context
WebSocketAdapter.onSendEvent hides an event from live subscribers when nip56.enabled and hideActionableReports are on and isHidden(event) is true. isHidden reads the worker's in-memory cache. On a worker that booted without reporting, an operator who turns reporting and hiding on later (settings reload or backup restore) activates the check, but the cache stays empty. A reported pubkey or event is still sent to open subscriptions until the next restart. REQ and COUNT are not affected, because they exclude reported targets in SQL.
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Non-functional change (docs, style, minor refactor)
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
My code follows the code style of this project.
My change requires a change to the documentation.
I have updated the documentation accordingly.
I have read the CONTRIBUTING document.
I have added tests to cover my code changes.
I added a changeset, or this is docs-only and I added an empty changeset.
All new and existing tests passed.
Summary by CodeRabbit
Bug Fixes
Changes to the hide-actionable-reports setting now take effect after the app has started, without requiring a restart.
Hidden-content handling now stays in sync with the current setting across workers. When the setting is off, hidden-content checks remain inactive; when it’s on, they run periodically.
No actionable comments were generated in the recent review.
Walkthrough
The worker now starts the hidden-content cache regardless of NIP-56 settings at boot. The cache checks settings on each tick and queries the database only when hideActionableReports is enabled.
workerFactory starts the cache unconditionally and passes createSettings for fresh settings checks. The test verifies there is no database read at boot when NIP-56 is unset, then verifies a read after hideActionableReports is enabled. The changeset records the behavior.
cameri/nostream#1157: This PR changes how cached settings reload after settings files change. That reload path affects which values the cache reads on each tick.
Merge Risk: Minimal · up to 3ac28
The hidden-content cache now starts on every worker, so enabling reporting and hiding later takes effect without a restart. Relays that do not use reporting only read settings on each tick and do not query the database. Merge risk is minimal.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: the NIP-56 hidden-content cache now starts on every worker. The raw summary and objectives both describe this change to workerFactory and its tests, so the title match…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check
Explanation
The title names the main change: the NIP-56 hidden-content cache now starts on every worker. The raw summary and objectives both describe this change to workerFactory and its tests, so the title matches the changeset. It uses the conventional fix(nip56) prefix and is specific.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks the settings each round, The cache wakes up when workers are found. No report flag at boot? That’s fine, It checks again along the line. When enabled, database reads begin, Then carrots await with a satisfied grin.
Recent review info
Automatic approval policy
Commit: 3ac28808e46f.
Setting
Effective value
Source
Automatic approvals
Enabled
Global configuration
Merge risk
Minimal
Global configuration
Security risk
Not set
Global configuration
Not set means no limit was configured after inheritance. Use @coderabbitai configuration to inspect the resolved settings and their sources.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: c6a15fee-7748-4742-af45-798435a9b89b
Commits
Reviewing files that changed from the base of the PR and between 549a97d and 3ac2880.
Files selected for processing: 3
.changeset/hidden-content-cache-start-always.md
src/factories/worker-factory.ts
test/unit/factories/worker-factory.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
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
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.
Description
workerFactorystarted the NIP-56 hidden-content cache only whennip56.enabledwas true at boot:The cache already reads the settings on every tick and queries the database only while
hideActionableReportsis on, so it was built to pick up a later change. The boot condition defeated that: a worker that booted with reporting off never started the timer.nip56.enabledsays at boot;hidden-content-cache.ts: each tick still checkshideActionableReportsfirst, so a relay that does not use reporting reads the settings object every 30 seconds and never queries the database;worker-factory.tssays why the start is unconditional.Related Issue
Partly addresses #1022 (F-032). The other findings in that issue are handled separately.
Motivation and Context
WebSocketAdapter.onSendEventhides an event from live subscribers whennip56.enabledandhideActionableReportsare on andisHidden(event)is true.isHiddenreads the worker's in-memory cache. On a worker that booted without reporting, an operator who turns reporting and hiding on later (settings reload or backup restore) activates the check, but the cache stays empty. A reported pubkey or event is still sent to open subscriptions until the next restart. REQ and COUNT are not affected, because they exclude reported targets in SQL.How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist:
Summary by CodeRabbit