From 619291c6470cdc1943af9417930ec6e0fc98234c Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Wed, 8 May 2024 23:20:29 +0300 Subject: [PATCH] Specify the order of JavaScript assets loaded. Previously, we could face (a rare) race condition with the wrong order. This was caused by Turbolinks and our usage of "components" (e.g., the CodeOceanEditor). It could happen that Turbolinks fired the `turbolinks:load` event, as all XHR requests finished. In the event handler, we sometimes referred to other components. However, those components weren't initialized yet, potentially. This is due to Sprockets concatenating files in alphabetical order, ignoring our component dependencies. With this commit, we try to specify the required order and thus aim to implement a permanent fix. Fixes CODEOCEAN-FRONTEND-7W Fixes CODEOCEAN-FRONTEND-7D --- app/assets/javascripts/application.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 2eeeb357..ba76b2e1 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -19,4 +19,19 @@ //= require color_mode_picker // // app/assets +// --> Include some assets first, as they are used by other assets. +// --> Hence, the order specified here is important. +// +// 1. Some common base functions and monkey patches +//= require base +// 2. Programming groups are required by "channels/synchronized_editor_channel.js" +//= require programming_groups +// 3. The turtle library is required by "editor/turtle.js" +//= require turtle +// 4. Some channels are required by "editor/editor.js.erb" +//= require_tree ./channels +// 5. Require the editor components, as needed by "./editor.js" and "./community_solution.js" +//= require_tree ./editor +// +// All remaining assets are loaded in alphabetical order //= require_tree .