Skip to content

Commit 09dc1e5

Browse files
committed
Fix cable race condition
1 parent e8e7b66 commit 09dc1e5

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

TODOLIST.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
- [ ] Modify rejudge behavior
22
- Lower priority
33
- Separate contest and non-contest submissions
4+
- [ ] Virtual judge
45
- [ ] Batch upload testdata
56
- [ ] Revisit all JSON endpoints
67

app/javascript/pages/submissions/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import consumer from "../../channels/consumer"
2-
import { updateSubmissionDetail, updateMultipleSubmissions } from '../../helpers/submission_update'
2+
import { updateSubmissionDetail, updateMultipleSubmissions } from './submission_update'
33

44
export function initSubmissionCable() {
55
// id can be integer or array of integers

app/javascript/helpers/submission_update.js renamed to app/javascript/pages/submissions/submission_update.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ function updateResult(data, cable) {
8585
if (data['total_time']) $('#total-time').text(data['total_time'])
8686
if (data['total_memory']) $('#total-memory').text(data['total_memory'])
8787
if ('score' in data) $('#total-score').text(score_str(data['score']));
88-
if (!to_wait) cable.disconnect();
88+
// cable message may not always be in order, so delay disconnect to avoid race
89+
if (!to_wait) setTimeout(() => cable.disconnect(), 1000);
8990
}
9091

9192
export function updateSubmissionDetail(data, cable) {

0 commit comments

Comments
 (0)