Skip to content

Add thread-safe locking to request logging in BlazorWebWasm - #123390

Merged
oroztocil merged 2 commits into
oroztocil/asset-caching-test-fixfrom
copilot/sub-pr-123388
Jan 20, 2026
Merged

Add thread-safe locking to request logging in BlazorWebWasm#123390
oroztocil merged 2 commits into
oroztocil/asset-caching-test-fixfrom
copilot/sub-pr-123388

Conversation

CopilotAI commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

Description

Addresses feedback on #123388 regarding thread safety of the requestLogs List in the BlazorWebWasm test asset. The List was being accessed concurrently from multiple HTTP requests without synchronization, causing potential race conditions.

Changes

Added locking around all requestLogs access points:

  • Lock object: Introduced requestLogsLock for synchronization
  • Middleware Add(): Protected with lock in the logging middleware
  • GET endpoint: Returns ToList() snapshot under lock
  • DELETE endpoint: Protects Clear() operation with lock
varrequestLogs=newList<BlazorWebWasmRequestLog>();varrequestLogsLock=newobject();app.Use(async(context,next)=>{awaitnext.Invoke();varlogEntry=newBlazorWebWasmRequestLog(/*...*/);lock(requestLogsLock){requestLogs.Add(logEntry);}});app.MapGet("/request-logs",()=>{lock(requestLogsLock){returnrequestLogs.ToList();}});

Testing

No additional testing required - thread safety fix for existing functionality.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: oroztocil <79744616+oroztocil@users.noreply.github.com>
CopilotAI changed the title [WIP] Update Wasm.Build.Tests.Blazor.AssetCachingTests based on review feedbackAdd thread-safe locking to request logging in BlazorWebWasmJan 20, 2026
CopilotAI requested a review from oroztocilJanuary 20, 2026 17:42
@oroztocil
oroztocil marked this pull request as ready for review January 20, 2026 17:52
@oroztocil
oroztocil merged commit 05ff18c into oroztocil/asset-caching-test-fixJan 20, 2026
12 of 14 checks passed
@oroztocil
oroztocil deleted the copilot/sub-pr-123388 branch January 21, 2026 10:20
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Feb 21, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@oroztocil