Skip to content

Conversation

mirceahasegan
Copy link
Contributor

@mirceahasegan mirceahasegan commented Oct 6, 2025

Solution
• The SW should also monitor the windowFocusChanged$ event.
• When the window regains focus, the event will fire, the observable
emits true if the tab is still open which tells the UI it is safe to resume communication.

Checklist


Proposed solution

1.	The Service Worker (SW) exposes an observable isLaceTabActive$, which reports changes when:
- a window is closed 
- a tab is updated (URL changes)
- a tab is activated (user switches tabs)
3.	The UI subscribes to this observable.
4.	After ~30 seconds of inactivity, Chrome suspends the SW due to lack of focus.
5.	When the UI resubscribes to isLaceTabActive$ after the SW was suspended: 
- The observable restarts with its startWith value (false).
- Because the SW was suspended, no tab events (from step 1) have fired, so nothing updates the observable.
- As a result, the UI keeps seeing false and shows “Blockchain out of sync.”
6.	Returning to the tab does not fix the issue because no event is triggered to flip isLaceTabActive$ back to true.
7.	Clicking the menus works because trigger navigation changes so the tab.onUpdated event fires, which updates isLaceTabActive$ to true.

Testing

Manual testing

Screenshots

…y check

	1.	The Service Worker (SW) exposes an observable isLaceTabActive$,
	which reports changes when:
	•	a window is closed
	•	a tab is updated (URL changes)
	•	a tab is activated (user switches tabs)
	2.	The UI subscribes to this observable.
	3.	After ~30 seconds of inactivity, Chrome suspends the SW due to lack of focus.
	4.	When the UI resubscribes to isLaceTabActive$ after the SW was suspended:
	•	The observable restarts with its startWith value (false).
	•	Because the SW was suspended, no tab events (from step 1) have fired,
	so nothing updates the observable.
	•	As a result, the UI keeps seeing false and shows “Blockchain out of sync.”
	5.	Returning to the tab does not fix the issue because no event is triggered
	to flip isLaceTabActive$ back to true.
	6.	Clicking the menus works because trigger navigation changes so the tab.onUpdated event fires,
	which updates isLaceTabActive$ to true.

⸻

Solution
	•	The SW should also monitor the windowFocusChanged$ event.
	•	When the window regains focus, the event will fire, the observable
	emits true if the tab is still open	which tells the UI it is safe to resume communication.
@mirceahasegan mirceahasegan requested a review from a team as a code owner October 6, 2025 11:18
@mirceahasegan mirceahasegan self-assigned this Oct 6, 2025
Copy link

sonarqubecloud bot commented Oct 6, 2025

Copy link
Member

@mkazlauskas mkazlauskas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! 💪 🕵️ We should also review v2's 'views-extension' implementation to see if it also needs a similar fix

@lace-bot
Copy link
Collaborator

lace-bot commented Oct 6, 2025

Allure Report

allure-report-publisher generated test report!

processReports: ✅ test report for 904602e0

passed failed skipped flaky total result
Total 33 0 4 0 37

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.

3 participants