Skip to content

bug: Code runner hangs indefinitely when Judge0 API request fails to respond (No client-side timeout) #154

@Vachhani-Tapan

Description

@Vachhani-Tapan

Describe the Bug

Currently, in src/hooks/useCodeRunner.js, the function runWithJudge0 performs a standard fetch call to Judge0's public API to execute non-JS/HTML code submissions.

Unlike the local JavaScript runner (which enforces a strict 10-second execution window), the Judge0 runner has no client-side timeout limit. If the Judge0 service is down, experiences heavy latency, or gets rate-limited, the fetch request will remain pending indefinitely. Consequently, the "Run" button stays in a "Running..." state, and users are locked out of executing any code unless they refresh the page.

Affected Code

In src/hooks/useCodeRunner.js:

async function runWithJudge0(code, languageId) {
  const res = await fetch(
    `${JUDGE0_BASE}/submissions?base64_encoded=false&wait=true`,
    {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ source_code: code, language_id: languageId }),
    }
  );
  ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions