[Bug]: Dashboard widgets registered via OCA.Dashboard.register() sometimes never mount (spinner forever) – Vue 3 non-deep `callbacks` watcher race
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 62/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- javascript
- Bereich
- frontend
Rechercherichtung
Das Race liegt in apps/dashboard/src/DashboardApp.vue: Der nicht-deep callbacks-Watcher wird nicht ausgelöst, wenn register(app, callback) einen Schlüssel hinzufügt, daher wird rerenderPanels() nur am Ende von created() aufgerufen. Beginne mit dem Lesen des Watchers, register() und rerenderPanels(), und reproduziere dann mit gedrosseltem Netzwerk, sodass ein Widget nach der Antwort der Widgets-API registriert wird. Fertig, wenn ein spät registriertes Widget weiterhin gemountet wird, zum Beispiel indem rerenderPanels() in register() aufgerufen wird oder der Watcher deep gemacht wird, ohne bereits gemountete Panels zu brechen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration/webserver/proxy issue.
- This issue is not already reported on Github OR Nextcloud Community Forum (I've searched it).
- Nextcloud Server is up to date.
- I agree to follow Nextcloud's Code of Conduct.
Bug description
Dashboard widgets that use the JavaScript OCA.Dashboard.register() API (e.g. Recommended files, also Photos / Teams) sometimes show the loading spinner forever. A reload (F5), or going to Files and back, often fixes it. The server API returns the data every time (/ocs/v2.php/apps/recommendations/api/v1/recommendations/always → 200 with items), so the problem is in the frontend.
Root cause: in apps/dashboard/src/DashboardApp.vue (current master too):
watch: {
callbacks() {
this.$nextTick(() => this.rerenderPanels())
},
},
// ...
register(app, callback) {
this.callbacks[app] = callback
},
Since the move to Vue 3, a non-deep watcher on an object does not fire when a key is added (only when the whole object is replaced). So register() never triggers rerenderPanels(). The only call left is the one at the end of created(), which runs after GET /ocs/v2.php/apps/dashboard/api/v1/widgets (and the v2 item fetches) finish.
Widgets register in DOMContentLoaded (e.g. recommendations src/dashboard.js). That event only fires after all module scripts on the page and their chunks are loaded and executed (more than 100 chunk requests on our instance). If the widgets API response arrives before DOMContentLoaded, rerenderPanels() has already run. The callback is stored but never called, and the panel stays loading for good. With a warm browser cache, DOMContentLoaded fires earlier and the race is usually won. That is why the bug looks random and a reload "fixes" it. It shows up much more often behind a reverse proxy / tunnel with some latency.
Quick check of the Vue 3 behaviour:
const { reactive, watch } = require('vue') // 3.5.x
const data = reactive({ callbacks: {} })
let fired = 0
watch(() => data.callbacks, () => fired++)
data.callbacks.recommendations = () => {}
setTimeout(() => console.log(fired), 10) // -> 0
Suggested fix (applied locally on the compiled bundle, which fixes it for us):
register(app, callback) {
this.callbacks[app] = callback
+ this.$nextTick(() => this.rerenderPanels())
},
(or make the watcher deep: true). rerenderPanels() already skips panels that are mounted, so calling it more often is safe.
Steps to reproduce
- Enable the Recommendations app and keep "Recommended files" on the dashboard.
- Open the dashboard with an empty browser cache, or with extra network latency (DevTools throttling, or a reverse proxy/tunnel in front of Nextcloud).
- The "Recommended files" panel sometimes keeps spinning forever. In the network tab,
/recommendations/alwaysreturns the items, but the widget is never mounted.
Expected behavior
The widget mounts whenever its register() call happens, also when that is after the first rerenderPanels().
Nextcloud Server version
35 (35.0.2)
Operating system
Other (official nextcloud:35.0.2-apache Docker image)
PHP engine version
PHP 8.5
Web server
Apache (supported)
Database engine version
MariaDB
Is this bug present after an update or on a fresh install?
Not sure — first noticed on 35.0.2 (the bug is in the code since the dashboard moved to Vue 3)
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
- Default user-backend (database)
Configuration report
Not relevant (frontend race, reproducible from the code above)
List of activated Apps
dashboard 8.0.0, recommendations 8.0.0, photos 8.0.0, circles 35.0.0
Nextcloud Signing status
No errors before the local workaround patch of dist/dashboard-main.mjs
Nextcloud Logs
No server-side errors; all API requests return 200.
Additional info
Affects every widget that uses OCA.Dashboard.register() (recommendations, photos, circles/teams). API v2 widgets are not affected.
- Vorherrschende Sprache
- PHP
- Sterne
- 37.6k
- Forks
- 5.4k
- Ø Merge
- 1 T. 16 Std.
- Gemergte PRs (30 T.)
- 660
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus nextcloud/server
-
35-feedback
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Maintainer antworten meist innerhalb von 1 Tag
-
[Bug]:Evtl. vergeben @lazerg hat das heute übernommen. Offen0. Needs triage 35-feedback bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Link share editor: "Custom permissions" is checked for a new link shareEvtl. vergeben @lazerg hat das heute übernommen. Offen0. Needs triage bug feature: sharing regression
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
0. Needs triage 35-feedback bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in nextcloud/server
Ähnliche Issues
-
bug good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
quantum-php/framework#692 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 70/100
ajeetraina/awesome-docker-sbx#559 ·
-
PHP 8.6 supportOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
-
Saisie des adressesOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
pantaflex44/Tiquettes#116 · 1 Kommentar ·
-
dependencies enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
novalo-dev/Prestashop-MCP-Server#329 ·
Maintainer antworten meist innerhalb von 1 Tag