Fix longstanding issue TypeError: e.map is not a function (#5170)

Fixes #4868
This took so long to track down. I am convinced `@ts-expect-error` is
*always an error*.
This commit is contained in:
Jeremy Rifkin
2023-07-22 12:44:32 -05:00
committed by Matt Godbolt
parent f49843b805
commit aa207b4f56
2 changed files with 8 additions and 19 deletions
+7 -17
View File
@@ -56,8 +56,6 @@ import ICursorSelectionChangedEvent = editor.ICursorSelectionChangedEvent;
import {Compiler} from './compiler.js';
import {assert, unwrap} from '../assert.js';
import * as Sentry from '@sentry/browser';
const loadSave = new loadSaveLib.LoadSave();
const languages = options.languages;
@@ -1430,16 +1428,8 @@ export class Editor extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Edit
this.busyCompilers[compilerId] = true;
}
addSource(
arr: ResultLine[] | undefined,
sourcePane: string,
result: CompilationResult,
): ResultLineWithSourcePane[] {
addSource(arr: ResultLine[] | undefined, sourcePane: string): ResultLineWithSourcePane[] {
if (arr) {
if (typeof arr.map !== 'function') {
// temporary triage for https://github.com/compiler-explorer/compiler-explorer/issues/4868
Sentry.captureMessage(`arr.map isn't a function. Original result: ${JSON.stringify(result)}`, 'error');
}
const newArr: ResultLineWithSourcePane[] = arr.map(element => {
return {
sourcePane: sourcePane,
@@ -1459,21 +1449,21 @@ export class Editor extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Edit
compilerId: number | string,
): (ResultLine & {sourcePane: string})[] {
const compilerTitle = compilerName + ' #' + compilerId;
let all = this.addSource(result.stdout, compilerTitle, result);
let all = this.addSource(result.stdout, compilerTitle);
if (result.buildsteps) {
_.each(result.buildsteps, step => {
all = all.concat(this.addSource(step.stdout, compilerTitle, result));
all = all.concat(this.addSource(step.stderr, compilerTitle, result));
all = all.concat(this.addSource(step.stdout, compilerTitle));
all = all.concat(this.addSource(step.stderr, compilerTitle));
});
}
if (result.tools) {
_.each(result.tools, tool => {
all = all.concat(this.addSource(tool.stdout, tool.name + ' #' + compilerId, result));
all = all.concat(this.addSource(tool.stderr, tool.name + ' #' + compilerId, result));
all = all.concat(this.addSource(tool.stdout, tool.name + ' #' + compilerId));
all = all.concat(this.addSource(tool.stderr, tool.name + ' #' + compilerId));
});
}
all = all.concat(this.addSource(result.stderr, compilerTitle, result));
all = all.concat(this.addSource(result.stderr, compilerTitle));
return all;
}
+1 -2
View File
@@ -262,8 +262,7 @@ export class Executor extends Pane<ExecutorState> {
}
private errorResult(message: string): CompilationResult {
// @ts-expect-error: This is a valid CompilationResult
return {stdout: [], timedOut: false, code: -1, stderr: message};
return {stdout: [], timedOut: false, code: -1, stderr: [{text: message}]};
}
compile(bypassCache?: BypassCache): void {