feat: guard sync-over-async bridge for WASM compatibility#10
Merged
MarcelRoozekrans merged 2 commits intomainfrom Mar 27, 2026
Merged
feat: guard sync-over-async bridge for WASM compatibility#10MarcelRoozekrans merged 2 commits intomainfrom
MarcelRoozekrans merged 2 commits intomainfrom
Conversation
c967324 to
6ae497f
Compare
Sync methods on abstract base classes now check OperatingSystem.IsBrowser() and throw PlatformNotSupportedException on WASM/browser platforms where blocking on async would deadlock. On server/.NET runtimes, the sync bridge continues to work as before via .GetAwaiter().GetResult(). Guard applied to: - AsyncDbConnection: Open, Close, BeginTransaction, ChangeDatabase, Dispose - AsyncDbCommand: ExecuteReader, ExecuteNonQuery, ExecuteScalar, Prepare - AsyncDbDataReader: Read, NextResult, Close, Dispose - AsyncDbTransaction: Commit, Rollback, Dispose - AsyncDataAdapter: Fill, Update Adapter classes (AdapterDbConnection, etc.) are NOT affected — they override sync methods with direct delegation to the inner provider's native sync implementation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6ae497f to
fd43b2c
Compare
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
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.
Summary
OperatingSystem.IsBrowser()before calling.GetAwaiter().GetResult()PlatformNotSupportedExceptionwith a message pointing to the async counterpartHow it works
A shared
SyncBridge.ThrowIfBrowser()guard is called at the top of every sync method:What's guarded
AsyncDbConnectionOpen(),Close(),BeginTransaction(),ChangeDatabase(),Dispose()AsyncDbCommandExecuteReader(),ExecuteNonQuery(),ExecuteScalar(),Prepare()AsyncDbDataReaderRead(),NextResult(),Close(),Dispose()AsyncDbTransactionCommit(),Rollback(),Dispose()AsyncDataAdapterFill(),Update()Not affected
Adapter classes (
AdapterDbConnection, etc.) override sync methods with direct delegation to the inner provider's native sync implementation.Test plan
🤖 Generated with Claude Code