fix container assignment issue

This commit is contained in:
Fabian Freund
2026-01-21 05:57:07 +01:00
parent aa0c6ac2c4
commit 94fa5789f5
2 changed files with 16 additions and 1 deletions
@@ -46,6 +46,11 @@ class TabRepository extends _$TabRepository {
final _tabFromIntent = <String>{};
/// Tracks tabs currently being processed for container assignment to prevent
/// concurrent processing of the same tab (race condition protection)
/// See: https://github.com/FaFre/WebLibre/issues/139
final _tabsBeingProcessedForAssignment = <String>{};
bool hasLaunchedFromIntent(String? tabId) {
if (tabId == null) {
return false;
@@ -434,6 +439,16 @@ class TabRepository extends _$TabRepository {
event,
) async {
if (event.tabId != null) {
// Prevent concurrent processing of the same tab (race condition protection)
if (_tabsBeingProcessedForAssignment.contains(event.tabId)) {
logger.d(
'Skipping container assignment for tab ${event.tabId} - already being processed',
);
return;
}
_tabsBeingProcessedForAssignment.add(event.tabId!);
// ignore: only_use_keep_alive_inside_keep_alive
final tabState = ref.read(tabStateProvider(event.tabId));
if (tabState != null) {
@@ -41,7 +41,7 @@ final class TabRepositoryProvider
}
}
String _$tabRepositoryHash() => r'93afd4b4b6d007f02707bda0b860730b0dba5c5f';
String _$tabRepositoryHash() => r'763f5ea734abc854dfdc0c08d3f266fbd94bf931';
abstract class _$TabRepository extends $Notifier<void> {
void build();