Bug #90546
closedCharts won't render from time to time
100%
Description
From time to time while loading the dashboard I receive the following error in Browser Console:
Error: Module name "TYPO3/CMS/Dashboard/Contrib/chartjs" has not been loaded yet for context: _ https://requirejs.org/docs/errors.html#notloaded
Whenever this error occurs, the charts are not rendered. I guess because the chartjs module is missing ;)
I've no clue yet what's causing this issue, or how to reproduce.
Used browser: Firefox "73.0.1 (64-bit)" on ubuntu.
Updated by Daniel Siepmann over 4 years ago
Accordingly to https://requirejs.org/docs/errors.html#notloaded, the current implementation should be wrong.
Not sure how to adjust https://github.com/TYPO3/TYPO3.CMS/blob/master/Build/Sources/TypeScript/dashboard/Resources/Public/TypeScript/ChartInitializer.ts to generate the expected code, but https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/dashboard/Resources/Public/JavaScript/ChartInitializer.js currently contains:
define(['require', 'exports', 'jquery'], (function (e, t, n) { 'use strict'; let r = e('TYPO3/CMS/Dashboard/Contrib/chartjs');
Which should be:
define(['require', 'exports', 'jquery', 'TYPO3/CMS/Dashboard/Contrib/chartjs'], (function (e, t, n) { 'use strict'; let r = e('TYPO3/CMS/Dashboard/Contrib/chartjs');
See:
In particular, the following will not work:
//THIS WILL FAIL
define(['require'], function (require) {
var namedModule = require('name');
});This fails because requirejs needs to be sure to load and execute all dependencies before calling the factory function above. If a dependency array is given to define(), then requirejs assumes that all dependencies are listed in that array, and it will not scan the factory function for other dependencies. So, either do not pass in the dependency array, or if using the dependency array, list all the dependencies in it.
If part of a require() callback, all the dependencies need to be listed in the array:
require(['require', 'name'], function (require) {
var namedModule = require('name');
});Be sure that require('name') only occurs inside a define() definition function or a require() callback function, never in the global space by its own.
Updated by Markus Klein over 4 years ago
- Related to Feature #90440: Dashboard widget type: Bar chart added
Updated by Gerrit Code Review over 4 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63472
Updated by Andreas Fernandez over 4 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset cb5146db6566cc7e22aaf28f3faba6dd8be533f4.