Skip to content

Fix duplicate submissions and EditArea null pointer error#902

Closed
Copilot wants to merge 6 commits intosubmit-patchfrom
copilot/sub-pr-901
Closed

Fix duplicate submissions and EditArea null pointer error#902
Copilot wants to merge 6 commits intosubmit-patchfrom
copilot/sub-pr-901

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 7, 2026

Users reported duplicate submissions and a JavaScript error: Cannot read properties of null (reading 'parentNode') from edit_area_full.js.

Changes

Duplicate submission prevention

  • Add PassCheck.disabled = true when submission starts, reset on completion/error
  • Guard checks both isPassCheckRunning flag and disabled property: if (isPassCheckRunning || PassCheck.disabled)
  • Defense-in-depth: flag prevents programmatic race conditions, disabled prevents UI clicks and provides visual feedback

EditArea conflict resolution

  • Delete EditArea instance before replacing submitpage.php innerHTML
  • XMOJ site loads EditArea editor; userscript's HTML replacement orphans its DOM references
  • Safe to fail: wrapped in try-catch since instance may not exist

Debug instrumentation

  • Log submission flow when DebugMode enabled for future troubleshooting
// Before: single flag guard
if (isPassCheckRunning) return;

// After: dual guard + button state
if (isPassCheckRunning || PassCheck.disabled) return;
isPassCheckRunning = true;
PassCheck.disabled = true;  // Prevent UI clicks, show visual state
// Prevent EditArea accessing orphaned DOM nodes
if (typeof editAreaLoader !== 'undefined') {
    editAreaLoader.delete_instance('source');
}
document.querySelector("...").innerHTML = ...;  // Now safe

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.


Summary by cubic

Prevents duplicate submissions and double-running of PassCheck on submitpage.php, and fixes the EditArea teardown error when the page HTML is replaced. Improves error messages and makes button/state recovery reliable on network, timeout, or parse failures.

  • Bug Fixes
    • Guard PassCheck/Submit with isSubmitting and isPassCheckRunning; declare flags before handlers; also check and set PassCheck.disabled during runs.
    • Better error handling: RequestAPI onerror/ontimeout with user-friendly messages; safe JSON-parse fallback; catch submission/network errors; proceed if compile-check parse fails; reset Submit/PassCheck and flags in all paths; add DebugMode logs for click/request flow.
    • Delete EditArea instance before replacing HTML (try/catch) to avoid the parentNode null error.

Written for commit 808dce1. Summary will update on new commits.

Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
@pull-request-size pull-request-size bot added size/S and removed size/XS labels Feb 7, 2026
Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
@pull-request-size pull-request-size bot added size/M and removed size/S labels Feb 7, 2026
Copilot AI changed the title [WIP] Add isSubmitting flags to prevent multiple submissions Fix double submission and add error recovery for submission flows Feb 7, 2026
Copilot AI requested a review from PythonSmall-Q February 7, 2026 04:03
Copilot AI and others added 2 commits February 7, 2026 05:12
Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
@pull-request-size pull-request-size bot added size/L and removed size/M labels Feb 7, 2026
… check

Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
Copilot AI changed the title Fix double submission and add error recovery for submission flows Fix duplicate submissions and EditArea null pointer error Feb 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants