Skip to content

Commit 2b61b51

Browse files
authored
Merge pull request #8333 from sagemathinc/fix-latex-long-compile-8332
frontend/latex: fix #8332 by fixing checking for the NATS error message
2 parents f292db9 + cb6cc63 commit 2b61b51

File tree

9 files changed

+62
-43
lines changed

9 files changed

+62
-43
lines changed

src/packages/frontend/cspell.json

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,55 +7,58 @@
77
"CoCalc",
88
"dplyr",
99
"ggplot",
10+
"ipython",
1011
"ipywidgets",
1112
"katex",
13+
"knitr",
1214
"kucalc",
1315
"mathjax",
1416
"matplotlib",
17+
"Miniterm",
1518
"nbconvert",
1619
"nbgrader",
1720
"nbviewer",
1821
"Ollama",
1922
"onprem",
2023
"plotly",
24+
"rclass",
2125
"rereturn",
2226
"respawns",
2327
"Rmarkdown",
28+
"rtypes",
2429
"Sagemath",
2530
"sagews",
2631
"scikit",
2732
"statsmodels",
2833
"syncdb",
34+
"syncdoc",
2935
"syncstring",
3036
"tidyverse",
3137
"timetravel",
38+
"tolerations",
3239
"undelete",
3340
"undeleting",
34-
"tolerations",
35-
"rtypes",
36-
"rclass",
37-
"ipython",
38-
"Miniterm"
41+
"sagetex"
3942
],
4043
"ignoreWords": [
41-
"LLMs",
42-
"LLM",
4344
"antd",
45+
"immutablejs",
4446
"ipynb",
47+
"isdir",
4548
"kernelspec",
49+
"LLM",
50+
"LLMs",
51+
"MDLG",
4652
"medkit",
4753
"mesg",
54+
"mintime",
4855
"mistralai",
4956
"Popconfirm",
57+
"PoweroffOutlined",
58+
"reuseinflight",
5059
"vertexai",
5160
"vfill",
52-
"xsmall",
53-
"MDLG",
54-
"isdir",
55-
"mintime",
56-
"PoweroffOutlined",
57-
"immutablejs",
58-
"reuseinflight"
61+
"xsmall"
5962
],
6063
"flagWords": [],
6164
"ignorePaths": ["node_modules/**", "dist/**", "dist-ts/**", "build/**"],

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,16 @@ import {
3535
redux,
3636
} from "@cocalc/frontend/app-framework";
3737
import type { PageActions } from "@cocalc/frontend/app/actions";
38+
import { VideoChat } from "@cocalc/frontend/chat/video/video-chat";
3839
import { syncAllComputeServers } from "@cocalc/frontend/compute/sync-all";
3940
import { get_buffer, set_buffer } from "@cocalc/frontend/copy-paste-buffer";
4041
import { filenameMode } from "@cocalc/frontend/file-associations";
42+
import {
43+
chat,
44+
getSideChatActions,
45+
} from "@cocalc/frontend/frame-editors/generic/chat";
4146
import { open_new_tab } from "@cocalc/frontend/misc";
47+
import type { FragmentId } from "@cocalc/frontend/misc/fragment-id";
4248
import Fragment from "@cocalc/frontend/misc/fragment-id";
4349
import {
4450
delete_local_storage,
@@ -59,7 +65,7 @@ import {
5965
syntax2tool,
6066
} from "@cocalc/util/code-formatter";
6167
import {
62-
TIMEOUT_CALLING_PROJECT,
68+
IS_TIMEOUT_CALLING_PROJECT,
6369
TIMEOUT_CALLING_PROJECT_MSG,
6470
} from "@cocalc/util/consts/project";
6571
import {
@@ -103,12 +109,6 @@ import * as cm_doc_cache from "./doc";
103109
import { SHELLS } from "./editor";
104110
import { test_line } from "./simulate_typing";
105111
import { misspelled_words } from "./spell-check";
106-
import { VideoChat } from "@cocalc/frontend/chat/video/video-chat";
107-
import type { FragmentId } from "@cocalc/frontend/misc/fragment-id";
108-
import {
109-
chat,
110-
getSideChatActions,
111-
} from "@cocalc/frontend/frame-editors/generic/chat";
112112

113113
interface gutterMarkerParams {
114114
line: number;
@@ -388,7 +388,7 @@ export class Actions<
388388
});
389389

390390
this._syncstring.on("save-to-disk", () => {
391-
// incremenet save_to_disk counter, so that react components can
391+
// increment save_to_disk counter, so that react components can
392392
// react to save_to_disk event happening.
393393
this.set_reload("save_to_disk");
394394
});
@@ -1134,7 +1134,7 @@ export class Actions<
11341134
// need to check since this can get called by the close.
11351135
if (!this._syncstring) return;
11361136
// TODO: for now, just for the one syncstring obviously
1137-
// TOOD: this is probably naive and slow too...
1137+
// TOO: this is probably naive and slow too...
11381138
let cursors: Map<string, List<Map<string, any>>> = Map();
11391139
this._syncstring
11401140
.get_cursors({
@@ -1157,7 +1157,7 @@ export class Actions<
11571157
}
11581158

11591159
// Set the location of all of OUR cursors. This serves many purposes:
1160-
// -- propogate to other users via the syncstring.
1160+
// -- propagate to other users via the syncstring.
11611161
// -- setting uri fragment page= at top of browser, so URL link is useful
11621162
// -- don't delete trailing whitespace in lines with cursors
11631163
set_cursor_locs(locs: any[]): void {
@@ -1765,7 +1765,7 @@ export class Actions<
17651765
return;
17661766
}
17671767

1768-
// This implentation of goto_line only supports integer line numbers.
1768+
// This implementation of goto_line only supports integer line numbers.
17691769
// However, derived classes may support id's or other types of more general "lines".
17701770
try {
17711771
if (typeof line == "string") {
@@ -1912,7 +1912,7 @@ export class Actions<
19121912
if (typeof e != "string") throw Error("bug"); // make typescript happy
19131913
error = e;
19141914
}
1915-
if (error === TIMEOUT_CALLING_PROJECT) {
1915+
if (IS_TIMEOUT_CALLING_PROJECT(error)) {
19161916
error = TIMEOUT_CALLING_PROJECT_MSG;
19171917
}
19181918
this.setState({ error });
@@ -2100,7 +2100,7 @@ export class Actions<
21002100
const before = gutter_markers;
21012101
gutter_markers.map((info, id) => {
21022102
if (info !== undefined && info.get("gutter_id") === gutter_id && id) {
2103-
/* && id is to satify typescript */
2103+
/* && id is to satisfy typescript */
21042104
gutter_markers = gutter_markers.delete(id);
21052105
}
21062106
});
@@ -2622,7 +2622,7 @@ export class Actions<
26222622
if (type == "terminal") {
26232623
this.clear_terminal_command(id);
26242624
if (node.get("command") == "jupyter") {
2625-
// not reseting jupyter
2625+
// not resetting jupyter
26262626
return;
26272627
}
26282628
// we also wait until it is "back again with a prompt"

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export class Actions extends BaseActions<LatexEditorState> {
197197

198198
private init_ext_path(): void {
199199
if (this.knitr) {
200-
// changing the path to the (to be generated) tex file makes everyting else
200+
// changing the path to the (to be generated) tex file makes everything else
201201
// here compatible with the latex commands
202202
this.path = change_filename_extension(this.path, "tex");
203203
this.setState({ knitr: this.knitr, knitr_error: false });
@@ -225,7 +225,7 @@ export class Actions extends BaseActions<LatexEditorState> {
225225
) {
226226
this._last_syncstring_hash = hash;
227227
// there are two cases: the parent "master" file triggers the build (usual case)
228-
// or an included depdenency – i.e. where parent_file is set
228+
// or an included dependency – i.e. where parent_file is set
229229
if (this.parent_file != null && this.parent_file != this.path) {
230230
const parent_actions = this.redux.getEditorActions(
231231
this.project_id,
@@ -672,7 +672,7 @@ export class Actions extends BaseActions<LatexEditorState> {
672672
// kicks off a save of all relevant files
673673
// Obviously, do not make this save_all(true), because
674674
// that would end up calling this very function again
675-
// crashing the browser in an INFINITE RECURSSION
675+
// crashing the browser in an INFINITE RECURSION
676676
// (this was a bug for a while!).
677677
// Also, the save of the related files is NOT
678678
// explicit -- the user is only explicitly saving this

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export async function knitr(
4242
project_id,
4343
command: R_CMD,
4444
args: [...R_ARGS, expr],
45-
rundir: directory,
45+
runDir: directory,
4646
aggregate: time ? { value: time } : undefined,
4747
set_job_info,
4848
path,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export async function latexmk(
4040
project_id,
4141
command,
4242
args,
43-
rundir: head,
43+
runDir: head,
4444
aggregate: time,
4545
set_job_info,
4646
path,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export async function pythontex(
4646
project_id,
4747
aggregate,
4848
command,
49-
rundir: output_directory || directory,
49+
runDir: output_directory || directory,
5050
set_job_info,
5151
// for python plots -- https://github.com/sagemathinc/cocalc/issues/4203
5252
env: { MPLBACKEND: "Agg" },

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export async function sagetex(
6565
command: "sage",
6666
args: [s],
6767
set_job_info,
68-
rundir: output_directory || directory,
68+
runDir: output_directory || directory,
6969
aggregate: hash ? { value: hash } : undefined,
7070
path,
7171
});

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ import {
1010
ExecOpts,
1111
ExecOutput,
1212
} from "@cocalc/frontend/frame-editors/generic/client";
13+
import { IS_TIMEOUT_CALLING_PROJECT } from "@cocalc/util/consts/project";
14+
import { ExecOptsBlocking } from "@cocalc/util/db-schema/projects";
1315
import { separate_file_extension } from "@cocalc/util/misc";
1416
import { ExecuteCodeOutputAsync } from "@cocalc/util/types/execute-code";
15-
// import { TIMEOUT_CALLING_PROJECT } from "@cocalc/util/consts/project";
16-
import { TIMEOUT_CALLING_PROJECT } from "@cocalc/util/consts/project";
17-
import { ExecOptsBlocking } from "@cocalc/util/db-schema/projects";
1817
import { TIMEOUT_LATEX_JOB_S } from "./constants";
1918

2019
export function pdf_path(path: string): string {
@@ -112,7 +111,7 @@ interface RunJobOpts {
112111
command: string;
113112
env?: { [key: string]: string };
114113
project_id: string;
115-
rundir: string; // a directory! (output_directory if in /tmp, or the directory of the file's path)
114+
runDir: string; // a directory! (output_directory if in /tmp, or the directory of the file's path)
116115
set_job_info: (info: ExecuteCodeOutputAsync) => void;
117116
timeout?: number;
118117
path: string;
@@ -125,7 +124,7 @@ export async function runJob(opts: RunJobOpts): Promise<ExecOutput> {
125124
command,
126125
env,
127126
project_id,
128-
rundir,
127+
runDir,
129128
set_job_info,
130129
path,
131130
} = opts;
@@ -140,7 +139,7 @@ export async function runJob(opts: RunJobOpts): Promise<ExecOutput> {
140139
command,
141140
env,
142141
err_on_exit: false,
143-
path: rundir,
142+
path: runDir,
144143
project_id,
145144
timeout: TIMEOUT_LATEX_JOB_S,
146145
};
@@ -177,12 +176,12 @@ export async function runJob(opts: RunJobOpts): Promise<ExecOutput> {
177176
set_job_info(output);
178177
return output;
179178
} catch (err) {
180-
if (err === TIMEOUT_CALLING_PROJECT) {
179+
if (IS_TIMEOUT_CALLING_PROJECT(err)) {
181180
// This will eventually be fine, hopefully. We continue trying to get a reply.
182181
await new Promise((done) => setTimeout(done, 100));
183182
} else {
184183
throw new Error(
185-
"Unable to complete compilation. Check the project and try again...",
184+
"Unable to run the compilation. Please check up on the project.",
186185
);
187186
}
188187
}

src/packages/util/consts/project.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,22 @@ export const DOC_CLOUD_STORAGE_URL =
66
export const PROJECT_EXEC_DEFAULT_TIMEOUT_S = 60;
77

88
export const TIMEOUT_CALLING_PROJECT = "timeout";
9+
10+
const NATS_TIMEOUT_MSG = "NatsError: TIMEOUT";
11+
912
export const TIMEOUT_CALLING_PROJECT_MSG =
1013
"Timeout communicating with project.";
14+
15+
export const IS_TIMEOUT_CALLING_PROJECT = (err) => {
16+
if (err === TIMEOUT_CALLING_PROJECT || err === NATS_TIMEOUT_MSG) {
17+
return true;
18+
}
19+
20+
if (
21+
typeof err?.toString === "function" &&
22+
err?.toString() === NATS_TIMEOUT_MSG
23+
) {
24+
return true;
25+
}
26+
return false;
27+
};

0 commit comments

Comments
 (0)