Defect #44294
openCharts are broken: empty app/assets/javascripts/chart.min.js shadows vendor/javascript/chart.min.js
Description
Since the Chart.js ESM migration (#44018) every page that renders a chart fails with a JavaScript error and shows an empty canvas.
Cause¶
The changeset moved the library from app/assets/javascripts/chart.min.js to vendor/javascript/chart.min.js, but the old file was left behind as an empty file instead of being deleted. Both files are present in 7.0-stable and trunk:
$ ls -l app/assets/javascripts/chart.min.js vendor/javascript/chart.min.js -rw-r--r-- 0 app/assets/javascripts/chart.min.js -rw-r--r-- 207691 vendor/javascript/chart.min.js
The importmap pins the library by its logical name:
config/importmap.rb:12: pin "chart.js", preload: false, to: "chart.min.js"
Propshaft resolves chart.min.js through the asset load paths, and app/assets/javascripts comes before vendor/javascript. The empty file therefore wins, the browser receives a 0 byte module, and import('chart.js') resolves to a module without any exports.
Effect¶
chart.default is undefined, so instantiating the chart throws:
Uncaught (in promise) TypeError: Chart is not a constructor
showStats stats_controller.js:34
connect stats_controller.js:14
This affects every consumer of the dynamic import:
app/javascript/controllers/repositories/stats_controller.js(repository statistics)app/javascript/controllers/reports/details_controller.js(issue report details)
Steps to reproduce¶
- Open a project with a repository that has changesets
- Go to Repository and click "Statistics"
- The page renders, but the chart area stays empty and the browser console shows the error above
Verification¶
The served asset is the empty one:
GET /assets/chart.min-356a192b.js -> 200, 0 bytes
With the empty file removed, Propshaft resolves the correct file and the chart renders without any console error:
GET /assets/chart.min-cae696ba.js -> 200, 207691 bytes
Proposed fix¶
Delete the leftover empty file:
svn delete app/assets/javascripts/chart.min.js
No other change is needed. The importmap pin already resolves to vendor/javascript/chart.min.js once the shadowing file is gone.
Reproduced and verified on trunk with Propshaft in development mode. The same empty file is present in the 7.0-stable branch, so 7.0.0 is affected as well.