Skip to content

Commit

Permalink
Fix cable race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien1018 committed Oct 6, 2023
1 parent e8e7b66 commit 09dc1e5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions TODOLIST.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
- [ ] Modify rejudge behavior
- Lower priority
- Separate contest and non-contest submissions
- [ ] Virtual judge
- [ ] Batch upload testdata
- [ ] Revisit all JSON endpoints

Expand Down
2 changes: 1 addition & 1 deletion app/javascript/pages/submissions/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import consumer from "../../channels/consumer"
import { updateSubmissionDetail, updateMultipleSubmissions } from '../../helpers/submission_update'
import { updateSubmissionDetail, updateMultipleSubmissions } from './submission_update'

export function initSubmissionCable() {
// id can be integer or array of integers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ function updateResult(data, cable) {
if (data['total_time']) $('#total-time').text(data['total_time'])
if (data['total_memory']) $('#total-memory').text(data['total_memory'])
if ('score' in data) $('#total-score').text(score_str(data['score']));
if (!to_wait) cable.disconnect();
// cable message may not always be in order, so delay disconnect to avoid race
if (!to_wait) setTimeout(() => cable.disconnect(), 1000);
}

export function updateSubmissionDetail(data, cable) {
Expand Down

0 comments on commit 09dc1e5

Please sign in to comment.