From 88c6be88f11a26f7d3ff88ee287e0abbb64c1e54 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Wed, 24 Apr 2024 15:31:15 +0200 Subject: [PATCH] Fix race condition on JavaScript initializer Previously, ProgrammingGroups could have been undefined in rare cases. Therefore, we check whether the variable is properly defined before calling the method. Fixes CODEOCEAN-FRONTEND-7D --- app/assets/javascripts/channels/synchronized_editor_channel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/channels/synchronized_editor_channel.js b/app/assets/javascripts/channels/synchronized_editor_channel.js index 6f909328..2a02a8c8 100644 --- a/app/assets/javascripts/channels/synchronized_editor_channel.js +++ b/app/assets/javascripts/channels/synchronized_editor_channel.js @@ -4,7 +4,7 @@ $(document).on('turbolinks:load', function () { var editor = $('#editor'); var exercise_id = editor.data('exercise-id'); - if ($.isController('exercises') && ProgrammingGroups.is_other_user(current_contributor)) { + if ($.isController('exercises') && typeof ProgrammingGroups !== 'undefined' && ProgrammingGroups.is_other_user(current_contributor)) { App.synchronized_editor = App.cable.subscriptions.create({ channel: "SynchronizedEditorChannel", exercise_id: exercise_id