Skip to content

Conversation

@christian-byrne
Copy link
Contributor

@christian-byrne christian-byrne commented Oct 25, 2025

Summary

Fixes Pinia initialization error that occurred when the auth service worker tried to access stores before Pinia was set up.

Problem

The auth service worker was being imported at the top of main.ts, causing it to register immediately:

import '@/platform/auth/serviceWorker'  // Runs immediately on import

This happened before Pinia was initialized, causing an error when the service worker setup tried to use stores:

Error: [🍍]: "getActivePinia()" was called but there was no active Pinia.

Solution

Moved the service worker registration to after Pinia is set up but before mounting the app:

  .use(pinia)
  .use(i18n)
  .use(VueFire, {
    firebaseApp,
    modules: [VueFireAuth()]
  })

// Register auth service worker after Pinia is initialized (cloud-only)
if (isCloud) {
  void import('@/platform/auth/serviceWorker')
}

app.mount('#vue-app')

Benefits

  • ✅ Pinia stores are available when service worker setup runs
  • ✅ Still tree-shaken for non-cloud builds via dynamic import in if (isCloud)
  • ✅ Registers before mounting, so service worker is active from the start

Testing

  • Verified no Pinia errors in cloud builds
  • Verified tree-shaking still works (service worker code not in localhost builds)

┆Issue is synchronized with this Notion page by Unito

The auth service worker was being imported at the top of main.ts, causing it
to register immediately before Pinia was initialized. This caused errors when
the service worker setup tried to use Pinia stores:

Error: [🍍]: "getActivePinia()" was called but there was no active Pinia.

Fix:
- Removed service worker import from top-level imports
- Moved registration to after Pinia is set up (after .use(pinia))
- Still maintains tree-shaking via dynamic import wrapped in isCloud check

The service worker now registers after all app setup is complete but before
mounting, ensuring Pinia stores are available when setupCacheInvalidation
calls useCurrentUser().
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Oct 25, 2025
@github-actions
Copy link

github-actions bot commented Oct 25, 2025

🎨 Storybook Build Status

Build completed successfully!

⏰ Completed at: 10/25/2025, 03:02:03 AM UTC

🔗 Links


🎉 Your Storybook is ready for review!

@christian-byrne christian-byrne added needs-backport Fix/change that needs to be cherry-picked to the current feature freeze branch area:auth area:cloud branch:rh-test labels Oct 25, 2025
@github-actions
Copy link

github-actions bot commented Oct 25, 2025

🎭 Playwright Test Results

⚠️ Tests passed with flaky tests

⏰ Completed at: 10/25/2025, 03:15:52 AM UTC

📈 Summary

  • Total Tests: 499
  • Passed: 466 ✅
  • Failed: 0
  • Flaky: 2 ⚠️
  • Skipped: 31 ⏭️

📊 Test Reports by Browser

  • chromium: View Report • ✅ 457 / ❌ 0 / ⚠️ 2 / ⏭️ 31
  • chromium-2x: View Report • ✅ 2 / ❌ 0 / ⚠️ 0 / ⏭️ 0
  • chromium-0.5x: View Report • ✅ 1 / ❌ 0 / ⚠️ 0 / ⏭️ 0
  • mobile-chrome: View Report • ✅ 6 / ❌ 0 / ⚠️ 0 / ⏭️ 0

🎉 Click on the links above to view detailed test results for each browser configuration.

@github-actions
Copy link

Bundle Size Report

Summary

  • Raw size: 12.2 MB baseline 12.2 MB — 🔴 +5 B
  • Gzip: 2.48 MB baseline 2.48 MB — 🔴 +8 B
  • Brotli: 1.96 MB baseline 1.96 MB — 🟢 -80 B
  • Bundles: 56 current • 56 baseline • 12 added / 12 removed

Category Glance
App Entry Points 🔴 +5 B (3.29 MB) · Vendor & Third-Party ⚪ 0 B (5.36 MB) · Other ⚪ 0 B (2.55 MB) · Graph Workspace ⚪ 0 B (713 kB) · Panels & Settings ⚪ 0 B (294 kB) · UI Components ⚪ 0 B (12.3 kB) · + 3 more

Per-category breakdown
App Entry Points — 3.29 MB (baseline 3.29 MB) • 🔴 +5 B _Main entry bundles and manifests_ | File | Before | After | Δ Raw | Δ Gzip | Δ Brotli | | ---------------------------------------- | ------- | ------- | ----------------------- | ---------------------- | ----------------------- | | **assets/index-BVgv1FVh.js** _(new)_ | — | 2.67 MB | 🔴 +2.67 MB | 🔴 +556 kB | 🔴 +421 kB | | ~~assets/index-cez2Np8r.js~~ _(removed)_ | 2.67 MB | — | 🟢 -2.67 MB | 🟢 -556 kB | 🟢 -421 kB | | ~~assets/index-BPShjD-m.js~~ _(removed)_ | 614 kB | — | 🟢 -614 kB | 🟢 -114 kB | 🟢 -90.1 kB | | **assets/index-DTldZsVP.js** _(new)_ | — | 614 kB | 🔴 +614 kB | 🔴 +114 kB | 🔴 +90.1 kB |

Status: 2 added / 2 removed

Graph Workspace — 713 kB (baseline 713 kB) • ⚪ 0 B _Graph editor runtime, canvas, workflow orchestration_ | File | Before | After | Δ Raw | Δ Gzip | Δ Brotli | | -------------------------------------------- | ------ | ------ | ---------------------- | ---------------------- | ---------------------- | | ~~assets/GraphView-BrK6162n.js~~ _(removed)_ | 713 kB | — | 🟢 -713 kB | 🟢 -140 kB | 🟢 -108 kB | | **assets/GraphView-CVklPErU.js** _(new)_ | — | 713 kB | 🔴 +713 kB | 🔴 +140 kB | 🔴 +108 kB |

Status: 1 added / 1 removed

Views & Navigation — 8.15 kB (baseline 8.15 kB) • ⚪ 0 B _Top-level views, pages, and routed surfaces_ | File | Before | After | Δ Raw | Δ Gzip | Δ Brotli | | ------------------------------------------------- | ------- | ------- | ----------------------- | ----------------------- | ----------------------- | | ~~assets/UserSelectView-BL4_ODW6.js~~ _(removed)_ | 8.15 kB | — | 🟢 -8.15 kB | 🟢 -2.47 kB | 🟢 -2.15 kB | | **assets/UserSelectView-gdhVqEX6.js** _(new)_ | — | 8.15 kB | 🔴 +8.15 kB | 🔴 +2.47 kB | 🔴 +2.15 kB |

Status: 1 added / 1 removed

Panels & Settings — 294 kB (baseline 294 kB) • ⚪ 0 B _Configuration panels, inspectors, and settings screens_ | File | Before | After | Δ Raw | Δ Gzip | Δ Brotli | | ---------------------------------------------------- | ------- | ------- | ----------------------- | ----------------------- | ----------------------- | | ~~assets/CreditsPanel-CCjehNGS.js~~ _(removed)_ | 22.1 kB | — | 🟢 -22.1 kB | 🟢 -5.28 kB | 🟢 -4.6 kB | | **assets/CreditsPanel-CVROWLzP.js** _(new)_ | — | 22.1 kB | 🔴 +22.1 kB | 🔴 +5.28 kB | 🔴 +4.61 kB | | ~~assets/KeybindingPanel-B_IBHOm9.js~~ _(removed)_ | 15.2 kB | — | 🟢 -15.2 kB | 🟢 -3.76 kB | 🟢 -3.31 kB | | **assets/KeybindingPanel-DoNbCTYh.js** _(new)_ | — | 15.2 kB | 🔴 +15.2 kB | 🔴 +3.76 kB | 🔴 +3.31 kB | | **assets/ExtensionPanel-BDutyZBU.js** _(new)_ | — | 12.1 kB | 🔴 +12.1 kB | 🔴 +2.83 kB | 🔴 +2.48 kB | | ~~assets/ExtensionPanel-Dn_7ztBQ.js~~ _(removed)_ | 12.1 kB | — | 🟢 -12.1 kB | 🟢 -2.83 kB | 🟢 -2.48 kB | | ~~assets/AboutPanel-BJqN2D4l.js~~ _(removed)_ | 10.3 kB | — | 🟢 -10.3 kB | 🟢 -2.66 kB | 🟢 -2.35 kB | | **assets/AboutPanel-CuHLNuWf.js** _(new)_ | — | 10.3 kB | 🔴 +10.3 kB | 🔴 +2.66 kB | 🔴 +2.34 kB | | **assets/ServerConfigPanel-12Pa2tzU.js** _(new)_ | — | 8.2 kB | 🔴 +8.2 kB | 🔴 +2.17 kB | 🔴 +1.89 kB | | ~~assets/ServerConfigPanel-DcXow0tR.js~~ _(removed)_ | 8.2 kB | — | 🟢 -8.2 kB | 🟢 -2.17 kB | 🟢 -1.89 kB | | **assets/UserPanel-Bwro_Sxp.js** _(new)_ | — | 7.91 kB | 🔴 +7.91 kB | 🔴 +2.06 kB | 🔴 +1.79 kB | | ~~assets/UserPanel-x2oX6r0y.js~~ _(removed)_ | 7.91 kB | — | 🟢 -7.91 kB | 🟢 -2.06 kB | 🟢 -1.79 kB | | assets/settings-B-df0dZe.js | 20.7 kB | 20.7 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/settings-CI6OKvJn.js | 22.9 kB | 22.9 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/settings-CXGVj_nD.js | 24.5 kB | 24.5 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/settings-DfQ6dSJj.js | 31.6 kB | 31.6 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/settings-DJ2QgDzm.js | 25.2 kB | 25.2 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/settings-DRNLPMG6.js | 23.7 kB | 23.7 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/settings-DVVycxDc.js | 19.9 kB | 19.9 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/settings-G6Dybj1b.js | 24.1 kB | 24.1 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/settings-M6_GZccG.js | 26 kB | 26 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B |

Status: 6 added / 6 removed

UI Components — 12.3 kB (baseline 12.3 kB) • ⚪ 0 B _Reusable component library chunks_ | File | Before | After | Δ Raw | Δ Gzip | Δ Brotli | | ----------------------------------------------------------------- | ------- | ------- | ----------------------- | ----------------------- | ----------------------- | | ~~assets/ComfyQueueButton-B7r-xtuI.js~~ _(removed)_ | 11.1 kB | — | 🟢 -11.1 kB | 🟢 -2.75 kB | 🟢 -2.44 kB | | **assets/ComfyQueueButton-CI_caKUt.js** _(new)_ | — | 11.1 kB | 🔴 +11.1 kB | 🔴 +2.76 kB | 🔴 +2.44 kB | | assets/UserAvatar.vue_vue_type_script_setup_true_lang-C9bSkTC5.js | 1.12 kB | 1.12 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B |

Status: 1 added / 1 removed

Data & Services — 10 kB (baseline 10 kB) • ⚪ 0 B _Stores, services, APIs, and repositories_ | File | Before | After | Δ Raw | Δ Gzip | Δ Brotli | | ---------------------------------------------------- | ------- | ------- | ----------------------- | ----------------------- | ---------------------- | | **assets/keybindingService-B8rBezQz.js** _(new)_ | — | 7.21 kB | 🔴 +7.21 kB | 🔴 +1.75 kB | 🔴 +1.5 kB | | ~~assets/keybindingService-Bk8GdGLr.js~~ _(removed)_ | 7.21 kB | — | 🟢 -7.21 kB | 🟢 -1.75 kB | 🟢 -1.5 kB | | assets/serverConfigStore-CvX_HMTJ.js | 2.79 kB | 2.79 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B |

Status: 1 added / 1 removed

Utilities & Hooks — 1.07 kB (baseline 1.07 kB) • ⚪ 0 B _Helpers, composables, and utility bundles_ | File | Before | After | Δ Raw | Δ Gzip | Δ Brotli | | --------------------------- | ------- | ------- | ------------------ | ------------------ | ------------------ | | assets/mathUtil-CTARWQ-l.js | 1.07 kB | 1.07 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B |
Vendor & Third-Party — 5.36 MB (baseline 5.36 MB) • ⚪ 0 B _External libraries and shared vendor chunks_ | File | Before | After | Δ Raw | Δ Gzip | Δ Brotli | | --------------------------------------- | ------- | ------- | ------------------ | ------------------ | ------------------ | | assets/vendor-other-EuL9bHKm.js | 3.22 MB | 3.22 MB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/vendor-primevue-PESgPnbc.js | 517 B | 517 B | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/vendor-tiptap-DY0_3CMM.js | 232 kB | 232 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/vendor-visualization-BEfdbjRw.js | 1.82 MB | 1.82 MB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/vendor-vue-Di9L6lvm.js | 92.4 kB | 92.4 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B |
Other — 2.55 MB (baseline 2.55 MB) • ⚪ 0 B _Bundles that do not match a named category_ | File | Before | After | Δ Raw | Δ Gzip | Δ Brotli | | --------------------------- | ------- | ------- | ------------------ | ------------------ | ------------------ | | assets/commands-B2KZRBmX.js | 15.1 kB | 15.1 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/commands-Bw-ckyga.js | 13.9 kB | 13.9 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/commands-C_NmM85I.js | 13.8 kB | 13.8 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/commands-CuozCW4W.js | 14 kB | 14 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/commands-DGfVUJCR.js | 16.2 kB | 16.2 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/commands-dOJNDogK.js | 14.5 kB | 14.5 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/commands-DwiE551e.js | 14.7 kB | 14.7 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/commands-Fw7mvqSy.js | 13.1 kB | 13.1 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/commands-FXnO1W4Q.js | 13.2 kB | 13.2 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/main-Bgu6_Hvd.js | 59.5 kB | 59.5 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/main-Bv0L0qvp.js | 93 kB | 93 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/main-C3Doz3n_.js | 67.6 kB | 67.6 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/main-C7eBl607.js | 70.7 kB | 70.7 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/main-CHiV9ds2.js | 76.4 kB | 76.4 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/main-CIc79Nts.js | 68.5 kB | 68.5 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/main-DK5LmuBm.js | 58.8 kB | 58.8 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/main-J1nit7cj.js | 66.3 kB | 66.3 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/main-W97XgvAQ.js | 80.4 kB | 80.4 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/nodeDefs-8Ef8lY1m.js | 196 kB | 196 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/nodeDefs-BdF8EiZl.js | 200 kB | 200 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/nodeDefs-Bv9Y8Cvp.js | 229 kB | 229 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/nodeDefs-cMdB_wHv.js | 179 kB | 179 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/nodeDefs-CvNWbbtX.js | 194 kB | 194 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/nodeDefs-CwDWxzVz.js | 215 kB | 215 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/nodeDefs-CyPAVHpA.js | 191 kB | 191 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/nodeDefs-D6QTD6bJ.js | 181 kB | 181 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B | | assets/nodeDefs-DKn6VmRJ.js | 192 kB | 192 kB | ⚪ 0 B | ⚪ 0 B | ⚪ 0 B |

@christian-byrne christian-byrne merged commit bab4786 into main Oct 25, 2025
48 of 49 checks passed
@christian-byrne christian-byrne deleted the fix-service-worker-pinia-timing branch October 25, 2025 03:16
@github-actions
Copy link

@christian-byrne Backport to rh-test failed: Merge conflicts detected.

Please manually cherry-pick commit bab47869c96b34b4e124a682c1880519fbda2e3a to the rh-test branch.

Conflicting files
  • src/main.ts

christian-byrne added a commit that referenced this pull request Oct 25, 2025
…tup (#6272)

Fixes Pinia initialization error that occurred when the auth service
worker tried to access stores before Pinia was set up.

The auth service worker was being imported at the top of `main.ts`,
causing it to register immediately:

```typescript
import '@/platform/auth/serviceWorker'  // Runs immediately on import
```

This happened before Pinia was initialized, causing an error when the
service worker setup tried to use stores:

```
Error: [🍍]: "getActivePinia()" was called but there was no active Pinia.
```

Moved the service worker registration to after Pinia is set up but
before mounting the app:

```typescript
  .use(pinia)
  .use(i18n)
  .use(VueFire, {
    firebaseApp,
    modules: [VueFireAuth()]
  })

// Register auth service worker after Pinia is initialized (cloud-only)
if (isCloud) {
  void import('@/platform/auth/serviceWorker')
}

app.mount('#vue-app')
```

- ✅ Pinia stores are available when service worker setup runs
- ✅ Still tree-shaken for non-cloud builds via dynamic import in `if
(isCloud)`
- ✅ Registers before mounting, so service worker is active from the
start

- Verified no Pinia errors in cloud builds
- Verified tree-shaking still works (service worker code not in
localhost builds)

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-6272-bugfix-fix-service-worker-registration-timing-to-run-after-Pinia-setup-2976d73d365081b998dfd2eded782070)
by [Unito](https://www.unito.io)
christian-byrne added a commit that referenced this pull request Oct 25, 2025
…r Pinia setup (#6272) (#6273)

Backport of #6272 to rh-test

## Summary

Fixes the Pinia initialization error by moving service worker
registration to after Pinia is initialized in the app setup flow.

## Problem

The service worker was being registered before Pinia was initialized,
causing:
```
Error: [🍍]: "getActivePinia()" was called but there was no active Pinia.
```

## Solution

Moved the dynamic import of the service worker to execute after Pinia
setup but before app mounting, while preserving the tree-shaking pattern
for cloud-only builds.

## Test Plan

- [x] Typecheck passes
- [x] Verify service worker registers correctly in cloud build
- [x] Verify no Pinia initialization errors

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-6273-backport-rh-test-fix-service-worker-registration-timing-to-run-after-Pinia-setup-6272-2976d73d365081d6bd19fa0f77f66254)
by [Unito](https://www.unito.io)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:auth area:cloud branch:rh-test needs-backport Fix/change that needs to be cherry-picked to the current feature freeze branch size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants