Skip to content

Commit 3f3b718

Browse files
committed
frontend/latex: edge case, resource usage stats not available for very short running compilation jobs
1 parent 41f825f commit 3f3b718

File tree

1 file changed

+18
-11
lines changed
  • src/packages/frontend/frame-editors/latex-editor

1 file changed

+18
-11
lines changed

src/packages/frontend/frame-editors/latex-editor/build.tsx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ export const Build: React.FC<Props> = React.memo((props) => {
7070
logContainerRef.current.scrollTop = logContainerRef.current.scrollHeight;
7171
}
7272
if (stderrContainerRef.current) {
73-
stderrContainerRef.current.scrollTop = stderrContainerRef.current.scrollHeight;
73+
stderrContainerRef.current.scrollTop =
74+
stderrContainerRef.current.scrollHeight;
7475
}
7576
}, [shownLog]);
7677

@@ -207,13 +208,17 @@ export const Build: React.FC<Props> = React.memo((props) => {
207208
// const time: number | undefined = x.get("time");
208209
// const time_str = time ? `(${(time / 1000).toFixed(1)} seconds)` : "";
209210
let job_info_str = "";
210-
// if (y != null && y.type === "async") {
211+
// Show build time and resource usage if available for async jobs
211212
if (x.type === "async") {
212-
const { elapsed_s, stats } = x; // y
213+
const { elapsed_s, stats } = x;
213214
if (typeof elapsed_s === "number" && elapsed_s > 0) {
214215
job_info_str = `Build time: ${elapsed_s.toFixed(1)} seconds.`;
215216
}
216-
job_info_str += getResourceUsage(stats, "peak");
217+
218+
// try to show peak resource usage if stats are available
219+
if (stats) {
220+
job_info_str += getResourceUsage(stats, "peak");
221+
}
217222
}
218223
const title = BUILD_SPECS[stage].label;
219224
// highlights tab, if there is at least one parsed error
@@ -381,13 +386,15 @@ export const Build: React.FC<Props> = React.memo((props) => {
381386
{status}
382387
{"\n"}
383388
</div>
384-
<div style={{
385-
flex: 1,
386-
display: "flex",
387-
flexDirection: "column",
388-
gap: hasStdout && hasStderr ? "10px" : "0",
389-
overflow: "hidden"
390-
}}>
389+
<div
390+
style={{
391+
flex: 1,
392+
display: "flex",
393+
flexDirection: "column",
394+
gap: hasStdout && hasStderr ? "10px" : "0",
395+
overflow: "hidden",
396+
}}
397+
>
391398
{hasStdout && (
392399
<div
393400
style={{

0 commit comments

Comments
 (0)