FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: make WrappedExpiringStorage finalizable and jitter expiry sweeps by jeswr · Pull Request #2224 · CommunitySolidServer/CommunitySolidServer · GitHub

fix: make WrappedExpiringStorage finalizable and jitter expiry sweeps - #2224

Open
jeswr wants to merge 3 commits into
CommunitySolidServer:versions/next-majorfrom
jeswr:codex/fix-expiring-storage-finalizable-next-major
Open

fix: make WrappedExpiringStorage finalizable and jitter expiry sweeps#2224
jeswr wants to merge 3 commits into
CommunitySolidServer:versions/next-majorfrom
jeswr:codex/fix-expiring-storage-finalizable-next-major

Conversation

jeswr commented Aug 22, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

📁 Related issues

Related to #2223.

This is the versions/next-major port of jeswr/CommunitySolidServer#79.

✍️ Description

Makes WrappedExpiringStorage implement Finalizable and clears its periodic expiry-sweep interval during graceful shutdown. The four instances created by the default identity configuration—cookies, forgot-password data, OIDC adapter data, and ownership tokens—are registered with the application finalizer. The previously anonymous OIDC adapter storage receives an identifier so it can be referenced by its FinalizableHandler.

The sweep interval also receives a configurable random positive jitter, defaulting to at most 15%, so instances constructed together do not enumerate their backing stores at the same instant. Passing 0 disables jitter, and the timer remains unref'd as a safety net.

The next-major port retains the v8 global logger import and adds the asynchronous-handlers context where the new ParallelHandler configuration requires it.

Suggested label: semver.minor.

Review question: should the 15% jitter remain the default, or should existing configurations retain an exact hourly cadence unless they opt in?

Validation:

  • npm run build under Node.js 24
  • full ESLint and Markdown lint under Node.js 24
  • npm run test:ts under Node.js 24
  • full unit gate: 339 suites and 2,279 tests passed
  • WrappedExpiringStorage.test.ts: 17 tests passed under Node.js 24
  • relevant integration/config boots passed, including identity, accounts, v6 migration, restricted identity, dynamic pods, and expiring-data cleanup

✅ PR check list

Before this pull request can be merged, a core maintainer will check whether

  • this PR is labeled with the correct semver label - this is a patch, I do not have permission to apply labels
    • semver.patch: Backwards compatible bug fixes.
  • the correct branch is targeted. Patch updates can target main, other changes should target the latest versions/* branch.
  • the RELEASE_NOTES.md document in case of relevant feature or config changes.
  • any relevant documentation was updated to reflect the changes in this PR.

Jesse Wright and others added 2 commits August 22, 2026 14:32
WrappedExpiringStorage arms a periodic expiry-sweep interval but only
unref'd it, so the timer was never cleared on a graceful shutdown and the
instances were part of no finalizer chain. Restore the Finalizable
contract: the class again implements Finalizable and exposes finalize(),
which clearInterval()s the timer (unref is kept as a safety net). All four
config-instantiated instances (cookies, forgot-password, OIDC adapter,
ownership tokens) are wired into urn:solid-server:default:Finalizer via
FinalizableHandler.

The four instances are all created at startup and swept on the same fixed
cadence, so their sweeps thundered together and caused periodic latency
spikes. Add an optional jitter constructor parameter (fraction of the
timeout, default 0.15) that randomly offsets each instance's interval so
the sweeps spread out. The parameter is optional and wired through
Components.js with a TS default, so existing configs are unchanged, and
jitter is injectable (jitter = 0 disables it) for deterministic tests.

Both changes are invisible to Solid clients: sweeps still run on
essentially the same cadence; only shutdown cleanup and inter-instance
scheduling change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The added JSDoc was more verbose than the surrounding storage source;
condense the class doc to the load-bearing facts (jittered sweep
interval, timer cleared on finalize), fold the jitter rationale into
one clause, and drop the finalize() method doc to match the other
Finalizable implementations (the interface carries the contract).
No behaviour change.

Model: claude-fable-5
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

jeswr left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is a configuration change so should be documented in the release notes

jeswr commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the release-note feedback in 99c9845 by documenting the default configuration finalization changes and the new Finalizable/jitter interface behavior.

jeswr marked this pull request as ready for review August 22, 2026 15:20
Copilot AI lite review requested due to automatic review settings August 22, 2026 15:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

This PR improves lifecycle management for expiring key-value storages by making WrappedExpiringStorage finalizable (so its periodic sweep timer is stopped during graceful shutdown) and desynchronizing sweep schedules via configurable jitter. It also updates the default identity configuration to register the relevant storages with the application finalizer and expands unit test coverage for the new timer behavior.

Changes:

  • Make WrappedExpiringStorage implement Finalizable, clear its sweep interval on finalize(), and add a configurable sweep-interval jitter (default 15%).
  • Register default identity WrappedExpiringStorage instances with the server finalizer (cookies, forgot-password, OIDC adapter storage, ownership tokens) and add an identifier for the adapter storage.
  • Update unit tests and release notes to cover/describe the new scheduling and shutdown behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/unit/storage/keyvalue/WrappedExpiringStorage.test.ts Adds unit tests for sweep scheduling (including jitter), unref(), sweep execution, and finalization cleanup.
src/storage/keyvalue/WrappedExpiringStorage.ts Implements Finalizable, adds jittered scheduling for sweep interval, and clears the timer during finalization.
RELEASE_NOTES.md Documents finalizer registration expectations and the new optional jitter behavior.
config/identity/ownership/token.json Registers ownership-token expiring storage with the application finalizer; adds async-handlers context.
config/identity/handler/storage/password.json Registers forgot-password expiring storage with the application finalizer; adds async-handlers context.
config/identity/handler/storage/default.json Registers cookie expiring storage with the application finalizer.
config/identity/handler/base/adapter-factory.json Gives the OIDC adapter expiring storage an @id and registers it with the application finalizer; adds async-handlers context.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

jeswr commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

This has been reviewed by me and is ready for maintainer 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
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.

2 participants


Back | FazBrowse Home | New Git URL