a9e8f5abfe
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
42 lines
2.5 KiB
C#
42 lines
2.5 KiB
C#
namespace ZB.MOM.WW.OtOpcUa.AdminUI.ScriptAnalysis;
|
|
|
|
/// <summary>Size limits for moving Monaco editor text across the Blazor Server circuit.</summary>
|
|
/// <remarks>
|
|
/// The editor text crosses JS → .NET only on demand (at blur and when a page saves), never per keystroke. Each
|
|
/// crossing is ONE SignalR message, bounded by the Blazor hub's <c>MaximumReceiveMessageSize</c>. The framework
|
|
/// default is 32 KB, which silently lost any larger script (the oversize invoke failed and Save persisted the
|
|
/// stale source), so <c>AddAdminUI</c> raises it to <see cref="HubMaximumReceiveMessageSize"/>. The editor JS
|
|
/// refuses to send a value whose serialized form exceeds <see cref="MaxEditorSyncBytes"/> — an oversize frame
|
|
/// would tear the circuit down — and the save surfaces that refusal to the author instead.
|
|
/// </remarks>
|
|
public static class ScriptEditorLimits
|
|
{
|
|
/// <summary>The Blazor hub's receive limit, in bytes (1 MB).</summary>
|
|
public const long HubMaximumReceiveMessageSize = 1024 * 1024;
|
|
|
|
/// <summary>The largest serialized editor value the JS will send, leaving 64 KB of frame headroom.</summary>
|
|
public const int MaxEditorSyncBytes = (int)HubMaximumReceiveMessageSize - 64 * 1024;
|
|
|
|
/// <summary>
|
|
/// The most diagnostic markers the editor reports to .NET (for the Problems list) in one circuit message.
|
|
/// A non-C# paste produces several Roslyn errors per line; uncapped, a few thousand markers exceed the hub
|
|
/// limit and tear the circuit down. The JS sends the first N in display order (errors first) plus the total.
|
|
/// Monaco's own in-editor squiggles are local and stay uncapped (up to <see cref="MaxDiagnosticMarkers"/>).
|
|
/// </summary>
|
|
public const int MaxReportedMarkers = 200;
|
|
|
|
/// <summary>Each reported marker's message is truncated to this many characters before it crosses the circuit.</summary>
|
|
public const int MaxReportedMessageChars = 300;
|
|
|
|
/// <summary>
|
|
/// The most markers the diagnostics endpoint returns (errors first). Bounds the analysis response and the
|
|
/// marker set Monaco renders for pathological input; an error is always kept when one exists, so the
|
|
/// editor still rejects exactly what publish rejects.
|
|
/// </summary>
|
|
public const int MaxDiagnosticMarkers = 1000;
|
|
|
|
/// <summary>Each diagnostics-endpoint marker message is truncated to this many characters (a Roslyn message
|
|
/// can quote an arbitrarily long pasted token).</summary>
|
|
public const int MaxDiagnosticMessageChars = 1000;
|
|
}
|