fix(adminui): bound the diagnostics marker payload on both the endpoint and the circuit (D-a review r1)
I-1 - a non-C# paste produced thousands of Roslyn markers. The Problems-list report sent them all as one JS->.NET message, which could exceed the 1 MB hub limit and kill the circuit. The JS now sends at most MaxReportedMarkers (200) markers, errors first, each message cut to 300 chars, plus the total. ScriptProblemReport.FromEditor clamps again on arrival, and the Problems list shows "showing N of Total" / "+N more". The diagnostics endpoint also bounds its response: Distinct, errors first, MaxDiagnosticMarkers (1000), messages cut to 1000 chars. An error is always kept, so editor-accepts == publish-accepts. M-1 - drop the per-instance compilation lineage; analyses derive from BaseCompilation. M-2 - the VirtualTag modal clears its problems (and editor ref) on close and on a script reload. M-5 - an over-limit text is announced at blur (OnSyncRefused), not only at Save. Refs #745 Claude-Session: https://claude.ai/code/session_01Ub9hGmYLQvn9XETzw7CMsT
This commit is contained in:
@@ -169,11 +169,44 @@
|
||||
function syncValue(e) {
|
||||
if (!e.dirty) return;
|
||||
const v = e.editor.getValue();
|
||||
if (tooLargeMessage(e, v)) return; // stays dirty; the explicit save read reports the error
|
||||
if (tooLargeMessage(e, v)) {
|
||||
// Stays dirty; the explicit save read reports the error. Tell .NET once (a tiny message) so the
|
||||
// author sees a non-blocking notice now rather than only at Save.
|
||||
if (!e.tooLargeNotified) {
|
||||
e.tooLargeNotified = true;
|
||||
e.dotNetRef.invokeMethodAsync("OnSyncRefused", serializedBytes(v)).catch(function () {});
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (e.tooLargeNotified) {
|
||||
e.tooLargeNotified = false;
|
||||
e.dotNetRef.invokeMethodAsync("OnSyncRefused", 0).catch(function () {});
|
||||
}
|
||||
e.dirty = false;
|
||||
e.dotNetRef.invokeMethodAsync("OnValueChanged", v).catch(function () { e.dirty = true; });
|
||||
}
|
||||
|
||||
// The Problems-list report is ONE circuit message too. A non-C# paste yields thousands of markers, so only the
|
||||
// first maxReportedMarkers in display order (errors first, then by position — ScriptProblems.Order) cross, each
|
||||
// message cut to maxReportedMessageChars, plus the total so the list can say how many were left out.
|
||||
// Monaco's own squiggles (setModelMarkers) are local and stay uncapped.
|
||||
function severityOrder(a, b) {
|
||||
return (b.severity - a.severity) || (a.startLineNumber - b.startLineNumber) || (a.startColumn - b.startColumn);
|
||||
}
|
||||
function markerReport(e, markers) {
|
||||
const max = e.maxReportedMarkers || 200, maxChars = e.maxReportedMessageChars || 300;
|
||||
const shown = markers.slice().sort(severityOrder).slice(0, max).map(function (m) {
|
||||
const msg = typeof m.message === "string" && m.message.length > maxChars
|
||||
? m.message.substring(0, maxChars - 1) + "\u2026" : m.message;
|
||||
return {
|
||||
severity: m.severity, startLineNumber: m.startLineNumber, startColumn: m.startColumn,
|
||||
endLineNumber: m.endLineNumber, endColumn: m.endColumn, message: msg,
|
||||
code: typeof m.code === "string" ? m.code.substring(0, 64) : m.code
|
||||
};
|
||||
});
|
||||
return { markers: shown, total: markers.length };
|
||||
}
|
||||
|
||||
// A single body-level node for Monaco's overflow widgets (suggest / hover / parameter hints).
|
||||
// Rendering them here — outside any ancestor with a CSS transform (e.g. the theme's `.rise`
|
||||
// entrance animation) — keeps the position:fixed widgets viewport-correct. Without it, the
|
||||
@@ -215,6 +248,8 @@
|
||||
const e = {
|
||||
editor: editor, dotNetRef: dotNetRef, dirty: false,
|
||||
maxSyncBytes: options.maxSyncBytes || 0, reportMarkers: !!options.reportMarkers,
|
||||
maxReportedMarkers: options.maxReportedMarkers || 200, maxReportedMessageChars: options.maxReportedMessageChars || 300,
|
||||
tooLargeNotified: false,
|
||||
diagTimer: null, diagGeneration: 0, diagAbort: null
|
||||
};
|
||||
// Diagnostics: the 500 ms debounce delays the START of a request; the generation counter + AbortController
|
||||
@@ -229,7 +264,10 @@
|
||||
if (markers === null || generation !== e.diagGeneration || editors[id] !== e) return; // superseded
|
||||
e.diagAbort = null;
|
||||
monaco.editor.setModelMarkers(model, "otopcua", markers);
|
||||
if (e.reportMarkers) dotNetRef.invokeMethodAsync("OnMarkersChanged", markers).catch(function () {});
|
||||
if (e.reportMarkers) {
|
||||
const report = markerReport(e, markers);
|
||||
dotNetRef.invokeMethodAsync("OnMarkersChanged", report.markers, report.total).catch(function () {});
|
||||
}
|
||||
};
|
||||
e.scheduleDiagnostics = function () {
|
||||
e.diagGeneration++;
|
||||
|
||||
Reference in New Issue
Block a user