[PR #5832] [MERGED] fix(common): correctly load mock servers on initialization and workspace change #5372

Closed
opened 2026-03-17 02:49:36 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5832
Author: @anwarulislam
Created: 2/4/2026
Status: Merged
Merged: 2/5/2026
Merged by: @jamesgeorge007

Base: patchHead: fix/mockserver-initialization


📝 Commits (5)

  • 436005a fix: refactor initialization logic to use currentUser stream
  • 3aeb7e5 fix: improve mock server workspace synchronization with immediate watch
  • f370273 fix: update loading state management in mock server store and dashboard
  • 445a6ba fix: simplify loading mock servers logic in workspace synchronization
  • b31f21c chore: cleanup

📊 Changes

3 files changed (+42 additions, -17 deletions)

View changed files

📝 packages/hoppscotch-common/src/components/mockServer/MockServerDashboard.vue (+4 -1)
📝 packages/hoppscotch-common/src/composables/mockServerWorkspace.ts (+19 -16)
📝 packages/hoppscotch-common/src/newstore/mockServers.ts (+19 -0)

📄 Description

Closes FE-1079, FE-1126.

When reloading the page on the cloud offering, mock servers were not being loaded initially because useMockServerWorkspaceSync checked authentication synchronously with platform.auth.getCurrentUser(). Since Firebase's onAuthStateChanged is asynchronous, the auth state was null at component creation time, causing the initial mock server load to be skipped.

The issue only manifested after a page reload - navigating between pages worked fine because Firebase had already finished initialization.

Also, addresses the issue with the Mock server list not respecting the active workspace.


Summary by cubic

Refactored mock server initialization to use the currentUser stream, loading only when authenticated and visible. Prevents stale data on workspace changes and reduces unnecessary loads; also adds a reliable loading state to the dashboard.

  • Refactors

    • Switched to useReadonlyStream for currentUser and a combined, immediate watch with visibility to trigger loads.
    • Added loadServers helper; clear servers on team workspace changes and reload when eligible.
    • Removed onMounted init; rely on reactive updates and fallback to setMockServers([]) on load errors.
  • Bug Fixes

    • Dashboard spinner now binds to the store’s loading$ for accurate loading feedback.

Written for commit b31f21cca3. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/5832 **Author:** [@anwarulislam](https://github.com/anwarulislam) **Created:** 2/4/2026 **Status:** ✅ Merged **Merged:** 2/5/2026 **Merged by:** [@jamesgeorge007](https://github.com/jamesgeorge007) **Base:** `patch` ← **Head:** `fix/mockserver-initialization` --- ### 📝 Commits (5) - [`436005a`](https://github.com/hoppscotch/hoppscotch/commit/436005aa26d972ea7736f903439243c75fde6346) fix: refactor initialization logic to use currentUser stream - [`3aeb7e5`](https://github.com/hoppscotch/hoppscotch/commit/3aeb7e5c8170fd74531b2550691d8b406fad16b7) fix: improve mock server workspace synchronization with immediate watch - [`f370273`](https://github.com/hoppscotch/hoppscotch/commit/f370273397c43f574feb9202b0c890d32d76eac5) fix: update loading state management in mock server store and dashboard - [`445a6ba`](https://github.com/hoppscotch/hoppscotch/commit/445a6ba49b1f1f37e85f2bf7a540bc52d2cfa5b7) fix: simplify loading mock servers logic in workspace synchronization - [`b31f21c`](https://github.com/hoppscotch/hoppscotch/commit/b31f21cca3b59d5c4fe2a1b80f468f899743ecad) chore: cleanup ### 📊 Changes **3 files changed** (+42 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-common/src/components/mockServer/MockServerDashboard.vue` (+4 -1) 📝 `packages/hoppscotch-common/src/composables/mockServerWorkspace.ts` (+19 -16) 📝 `packages/hoppscotch-common/src/newstore/mockServers.ts` (+19 -0) </details> ### 📄 Description Closes FE-1079, FE-1126. When reloading the page on the cloud offering, mock servers were not being loaded initially because `useMockServerWorkspaceSync` checked authentication synchronously with `platform.auth.getCurrentUser()`. Since Firebase's `onAuthStateChanged` is asynchronous, the auth state was null at component creation time, causing the initial mock server load to be skipped. The issue only manifested after a page reload - navigating between pages worked fine because Firebase had already finished initialization. Also, addresses the issue with the Mock server list not respecting the active workspace. <!-- Add an introduction into what this PR tries to solve in a couple of sentences --> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Refactored mock server initialization to use the currentUser stream, loading only when authenticated and visible. Prevents stale data on workspace changes and reduces unnecessary loads; also adds a reliable loading state to the dashboard. - **Refactors** - Switched to useReadonlyStream for currentUser and a combined, immediate watch with visibility to trigger loads. - Added loadServers helper; clear servers on team workspace changes and reload when eligible. - Removed onMounted init; rely on reactive updates and fallback to setMockServers([]) on load errors. - **Bug Fixes** - Dashboard spinner now binds to the store’s loading$ for accurate loading feedback. <sup>Written for commit b31f21cca3b59d5c4fe2a1b80f468f899743ecad. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:49:36 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#5372
No description provided.