Bug #90546

Charts won't render from time to time

Added by Daniel Siepmann 3 months ago. Updated about 2 months ago.

Status:
Closed
Priority:
Should have
Category:
Dashboard
Target version:
Start date:
2020-02-27
Due date:
% Done:

100%

TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.


Related issues

Related to TYPO3 Core - Feature #90440: Dashboard widget type: Bar chart Closed 2020-02-19

Associated revisions

Revision cb5146db (diff)
Added by Andreas Fernandez 3 months ago

[BUGFIX] Import dependencies of dashboard properly

The dependencies of the dashboard are now properly imported to fix
loading issues.

Resolves: #90546
Releases: master
Change-Id: I9f86e9e9dc87082269cda777b373bc02df414153
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63472
Tested-by: TYPO3com <>
Tested-by: Daniel Goerz <>
Tested-by: Georg Ringer <>
Reviewed-by: Markus Klein <>
Reviewed-by: Daniel Goerz <>
Reviewed-by: Georg Ringer <>

History

#1 Updated by Daniel Siepmann 3 months 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.

#2 Updated by Georg Ringer 3 months ago

  • Status changed from New to Accepted

#3 Updated by Markus Klein 3 months ago

#4 Updated by Gerrit Code Review 3 months 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

#5 Updated by Andreas Fernandez 3 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#6 Updated by Benni Mack about 2 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF