Skip to content

Commit 514faba

Browse files
committed
frontend/latex: properly test if exec did timeout, for a proper retry
1 parent 07002cf commit 514faba

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

src/packages/frontend/frame-editors/code-editor/actions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import {
6464
syntax2tool,
6565
} from "@cocalc/util/code-formatter";
6666
import {
67-
IS_TIMEOUT_CALLING_PROJECT,
67+
isTimeoutCallingProject,
6868
TIMEOUT_CALLING_PROJECT_MSG,
6969
} from "@cocalc/util/consts/project";
7070
import {
@@ -1921,7 +1921,7 @@ export class Actions<
19211921
if (error === undefined) {
19221922
return "";
19231923
}
1924-
if (IS_TIMEOUT_CALLING_PROJECT(error)) {
1924+
if (isTimeoutCallingProject(error)) {
19251925
return TIMEOUT_CALLING_PROJECT_MSG;
19261926
}
19271927
if (typeof error == "string") {

src/packages/frontend/frame-editors/latex-editor/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
ExecOpts,
1111
ExecOutput,
1212
} from "@cocalc/frontend/frame-editors/generic/client";
13-
import { IS_TIMEOUT_CALLING_PROJECT } from "@cocalc/util/consts/project";
13+
import { isTimeoutCallingProject } from "@cocalc/util/consts/project";
1414
import { ExecOptsBlocking } from "@cocalc/util/db-schema/projects";
1515
import { separate_file_extension } from "@cocalc/util/misc";
1616
import { ExecuteCodeOutputAsync } from "@cocalc/util/types/execute-code";
@@ -177,7 +177,7 @@ export async function runJob(opts: RunJobOpts): Promise<ExecOutput> {
177177
set_job_info(output);
178178
return output;
179179
} catch (err) {
180-
if (IS_TIMEOUT_CALLING_PROJECT(err)) {
180+
if (isTimeoutCallingProject(err)) {
181181
// This will eventually be fine, hopefully. We continue trying to get a reply.
182182
await delay(100);
183183
} else {

src/packages/util/consts/project.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,20 @@ export const TIMEOUT_CALLING_PROJECT = "timeout";
1010
export const TIMEOUT_CALLING_PROJECT_MSG =
1111
"Timeout communicating with project.";
1212

13-
export const IS_TIMEOUT_CALLING_PROJECT = (err) => {
13+
/**
14+
* Checks if an error represents a timeout when communicating with a project.
15+
*
16+
* Handles both legacy and conat-based timeout errors:
17+
* - Legacy: String "timeout"
18+
* - Conat: ConatError with code 408 (HTTP Request Timeout)
19+
* See @cocalc/conat/core/client.ts lines 1391, 1937-1939 where 408 timeouts are thrown
20+
*/
21+
export function isTimeoutCallingProject(err): boolean {
1422
if (err === TIMEOUT_CALLING_PROJECT) {
1523
return true;
1624
}
25+
if (err?.constructor?.name === "ConatError" && err?.code === 408) {
26+
return true;
27+
}
1728
return false;
18-
};
29+
}

0 commit comments

Comments
 (0)