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

fix: keep write locks alive while request data is flowing by jeswr · Pull Request #2217 · CommunitySolidServer/CommunitySolidServer · GitHub

fix: keep write locks alive while request data is flowing - #2217

Open
jeswr wants to merge 3 commits into
CommunitySolidServer:mainfrom
jeswr:fix/write-lock-renewal
Open

fix: keep write locks alive while request data is flowing#2217
jeswr wants to merge 3 commits into
CommunitySolidServer:mainfrom
jeswr:fix/write-lock-renewal

Conversation

jeswr commented Aug 22, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

📁 Related issues

Closes #2215.

✍️ Description

LockingResourceStore already renews expiring locks while response streams are read. This change applies the same
protection to incoming representations used by addResource, setRepresentation, and modifyResource.

The write helper adapts the existing stream in place so representation and patch-specific properties are preserved.
Every read renews the held write lock. If that lock expires before the source call completes, the helper first restores
the exact original read function and then destroys the stream, preventing the source store from continuing an
unprotected write.

Lock-acquisition failures and source write errors do not destroy the request stream. The original read function is
restored after both successful and failed writes.

Validation:

  • Build and affected-file ESLint passed on current main.
  • Focused unit and integration suites: 2 suites / 21 tests passed after rebase.
  • Full unit suite: 358 suites / 2,379 tests passed with 100% source coverage.
  • Full integration suite: 28 suites / 808 tests passed; 3 suites / 23 tests skipped.

✅ 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 fix.
  • the correct branch is targeted: patch updates target main.
  • RELEASE_NOTES.md does not need an update for this internal bug fix.
  • No user-facing documentation changes are required.

Renew expiring write locks whenever incoming representation data is read. If a held lock expires mid-write, restore the stream hook and destroy the stream so the source cannot continue writing without protection.

jeswr commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

I confirm this is ready for review @joachimvh - I have already reviewed and applied my fixes jeswr#55

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 extends LockingResourceStore’s expiring-lock renewal behavior to write operations by keeping write locks alive while incoming request body streams are being read, and aborting the incoming stream if the write lock expires mid-write (addressing #2215).

Changes:

  • Add lockedRepresentationWrite to wrap incoming representation streams so each read() call renews the write lock, and destroy the stream on lock-expiry mid-write.
  • Route addResource, setRepresentation, and modifyResource through the new write-lock streaming helper.
  • Add/extend unit and integration tests to cover lock renewal on reads and stream destruction on write-timeouts.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/storage/LockingResourceStore.ts Introduces a write-path stream adaptation to renew write locks on read() and destroy the incoming stream if the lock expires mid-write.
test/unit/storage/LockingResourceStore.test.ts Adds unit tests verifying lock renewal per read(), restoration of the original read, and stream destruction behavior on lock expiry vs. other errors.
test/integration/LockingResourceStore.test.ts Adds integration coverage ensuring incoming streams are destroyed on write-timeouts (no reads / long pauses).

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

jeswr and others added 2 commits August 22, 2026 14:11
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

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.

Write locks can expire while request bodies are still streaming

2 participants


Back | FazBrowse Home | New Git URL