Skip to content

Commit 5959d3a

Browse files
authored
Enforce SendPendingMessages in dispatch queue (#14487)
* Make ExperimentalFeatures overridable * Enforce SendPendingMessages in dispatch queue * Add WinUI 3 MSO UT packages lock file * Change files * Return if actual write fails * Remove unrelated lock file * Revert ExperimentalFeatures.props
1 parent 3ec1a7f commit 5959d3a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Enforce SendPendingMessages in dispatch queue",
4+
"packageName": "react-native-windows",
5+
"email": "julio.rocha@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

vnext/Shared/Networking/WinRTWebSocketResource.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,10 @@ fire_and_forget WinRTWebSocketResource2::PerformWrite(string &&message, bool isB
290290
}
291291

292292
IAsyncAction WinRTWebSocketResource2::SendPendingMessages() noexcept {
293+
// Enforcing execution in the background queue.
294+
// Awaiting of this coroutine will schedule its execution in the thread pool, ignoring the intended dispatch queue.
295+
co_await resume_in_queue(m_backgroundQueue);
296+
293297
auto self = shared_from_this();
294298

295299
while (!self->m_outgoingMessages.empty()) {
@@ -334,6 +338,7 @@ IAsyncAction WinRTWebSocketResource2::SendPendingMessages() noexcept {
334338
auto result = async.ErrorCode();
335339
if (result < 0) {
336340
Fail(std::move(result), ErrorType::Send);
341+
co_return;
337342
}
338343
}
339344
}

0 commit comments

Comments
 (0)