From 50942b4a759ae9e9ca60e90fcbda1fe2bc1b7fb9 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Fri, 13 Nov 2026 23:36:55 -0500 Subject: [PATCH] Retire pending Monaco creation before editor registration --- .../evidence/ot13-monaco-lifetime/README.md | 31 +++ .../evidence/ot13-monaco-lifetime/green.log | 55 +++++ .../evidence/ot13-monaco-lifetime/green.trx | 208 ++++++++++++++++++ .../ot13-monaco-lifetime/js-green.json | 71 ++++++ .../ot13-monaco-lifetime/js-green.log | 1 + .../js-initial-harness-wait.log | 30 +++ .../js-initial-loader-origin.log | 34 +++ .../evidence/ot13-monaco-lifetime/js-red.json | 71 ++++++ .../evidence/ot13-monaco-lifetime/js-red.log | 1 + .../evidence/ot13-monaco-lifetime/red.log | 108 +++++++++ .../evidence/ot13-monaco-lifetime/red.trx | 51 +++++ .../ui-consistency/check_monaco_lifetime.py | 84 +++++++ .../Components/Shared/MonacoEditor.razor | 8 +- .../wwwroot/js/monaco-init.js | 17 +- .../MonacoCreationLifetimeTests.cs | 42 ++++ 15 files changed, 809 insertions(+), 3 deletions(-) create mode 100644 docs/ui-consistency/evidence/ot13-monaco-lifetime/README.md create mode 100644 docs/ui-consistency/evidence/ot13-monaco-lifetime/green.log create mode 100644 docs/ui-consistency/evidence/ot13-monaco-lifetime/green.trx create mode 100644 docs/ui-consistency/evidence/ot13-monaco-lifetime/js-green.json create mode 100644 docs/ui-consistency/evidence/ot13-monaco-lifetime/js-green.log create mode 100644 docs/ui-consistency/evidence/ot13-monaco-lifetime/js-initial-harness-wait.log create mode 100644 docs/ui-consistency/evidence/ot13-monaco-lifetime/js-initial-loader-origin.log create mode 100644 docs/ui-consistency/evidence/ot13-monaco-lifetime/js-red.json create mode 100644 docs/ui-consistency/evidence/ot13-monaco-lifetime/js-red.log create mode 100644 docs/ui-consistency/evidence/ot13-monaco-lifetime/red.log create mode 100644 docs/ui-consistency/evidence/ot13-monaco-lifetime/red.trx create mode 100644 infra/tools/ui-consistency/check_monaco_lifetime.py create mode 100644 tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/ScriptAnalysis/MonacoCreationLifetimeTests.cs diff --git a/docs/ui-consistency/evidence/ot13-monaco-lifetime/README.md b/docs/ui-consistency/evidence/ot13-monaco-lifetime/README.md new file mode 100644 index 000000000..82ed52810 --- /dev/null +++ b/docs/ui-consistency/evidence/ot13-monaco-lifetime/README.md @@ -0,0 +1,31 @@ +# Shared Monaco deferred-creation lifetime + +Scope is only shared MonacoEditor, its existing monaco-init.js adapter, a new MonacoCreationLifetimeTests class, a bounded JavaScript browser harness, and this evidence. No protocol, caller, default, marker payload, authoritative text, endpoint or package change is made. + +The new presentation keys required by caller target isolation exposed an existing creation race: createEditor awaits the AMD loader while `_initialized` remains false. Disposal previously skipped JS cleanup in that state and retired the DotNetObjectReference. The late JS continuation then created an editor for a retired host, installed it in the editor map and scheduled diagnostics against the retired reference. + +The component now tracks only in-progress initialization as well as completed initialization for disposal. It sends the existing JS dispose request for either state, remains uninitialized when the creation continuation finishes after disposal, and rejects later render work. Completed initialization failure keeps its original cleanup/exception behavior; no unconditional dispose call is added to failed/static initialization. Component disposal is idempotent. + +The JS adapter stores pending creation identities, removes them during dispose even when no editor exists yet, and validates that the same attempt is still current before creating an editor. The host must be connected both before starting the loader and after it resolves. Creation after the loader is synchronous, so the attempt is removed before the existing editor setup proceeds. Existing live editor disposal, diagnostic timer/abort cleanup, sync/blur/oversize handling and marker checks remain unchanged. No permanent retired-ID set or growth per closed editor is introduced. + +## Red and green + +- `red.trx`: one meaningful managed failure, zero skips. A real rendered component, with createEditor held by strict bUnit interop, was disposed before creation completed; no cancellation had been sent. +- `green.trx`: **30 passed, zero failed/skipped** across the new creation lifetime case and the six preceding read-only/accessibility/disposal/sync/source/equipment classes. The new case awaits the actual initial-render continuation through a test-only derived component; it proves pending cancellation uses the original ID, no later option update occurs and GetValue remains the pre-initialization bound-value path after retirement. No production seam is added. +- `js-red.json`: actual production monaco-init.js executed in Chromium with deferred synthetic AMD/Monaco APIs. Both disposed-during-loader and detached-during-loader scenes created an orphan, performed a diagnostic request and called the retired DotNet reference after 550ms. The live control passed. +- `js-green.json`: **three scenes passed /17 checks**. Both retired scenes now create zero editors, issue zero diagnostic requests/callbacks and have no mapped value; the live editor still exposes its value, forwards readOnly true/false through actual updateOptions and disposes exactly once. All page-error lists are empty. + +The JS harness uses the unchanged production adapter with a synthetic Monaco API, not the actual Monaco implementation. It proves pending registration, option forwarding and timer cleanup, not native Monaco typing, focus, rendering or assistive technology. It intercepts the sole local AMD loader request and uses no application host or external network. The modal worker owns native actual-Monaco pending/recovery acceptance. + +Two initial JavaScript harness attempts are retained honestly: the first accidentally awaited the pending creation promise before releasing its loader; the second lacked a loopback base URL for the synthetic document's relative loader. They were interrupted/corrected before the meaningful red scenes. They are not product failures. The final harness supplies a loopback base URL and defers/release-controls the AMD callback without awaiting creation prematurely. + +All managed tests used the mandatory private owned-loopback SQL runner even for filtered discovery. No private state/credential content was read or copied. Isolated artifacts are repository-anchored under `artifacts/ot13-monaco-lifetime`; package/framework versions are unchanged. + +Reproduce from the OtOpcUa repository root: + +```sh +python3 infra/tools/ui-consistency/check_monaco_lifetime.py --output docs/ui-consistency/evidence/ot13-monaco-lifetime/js-green.json +python3 infra/tools/ui-consistency/with_private_sql.py --state "$OT_PRIVATE_SQL_STATE" -- dotnet test tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/ZB.MOM.WW.OtOpcUa.AdminUI.Tests.csproj -c Debug --artifacts-path artifacts/ot13-monaco-lifetime --filter 'FullyQualifiedName~MonacoCreationLifetimeTests|FullyQualifiedName~MonacoReadOnlyTests|FullyQualifiedName~MonacoAccessibilityTests|FullyQualifiedName~MonacoEditorDisposeTests|FullyQualifiedName~MonacoSyncTests|FullyQualifiedName~MonacoInteropSourceTests|FullyQualifiedName~EquipTokenEditorTests' --logger 'trx;LogFileName=green.trx' --results-directory docs/ui-consistency/evidence/ot13-monaco-lifetime +``` + +No host/service/container lifecycle was changed by this slice. The browser context closes after each synthetic run. Whole-consumer integration and native modal acceptance remain separate OT13/OT14 gates. diff --git a/docs/ui-consistency/evidence/ot13-monaco-lifetime/green.log b/docs/ui-consistency/evidence/ot13-monaco-lifetime/green.log new file mode 100644 index 000000000..980bbbcb3 --- /dev/null +++ b/docs/ui-consistency/evidence/ot13-monaco-lifetime/green.log @@ -0,0 +1,55 @@ + + Determining projects to restore... + All projects are up-to-date for restore. + ZB.MOM.WW.OtOpcUa.Analyzers -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Analyzers/debug/ZB.MOM.WW.OtOpcUa.Analyzers.dll + ZB.MOM.WW.OtOpcUa.Driver.Calculation.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Calculation.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.Calculation.Contracts.dll + ZB.MOM.WW.OtOpcUa.Core.Abstractions -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Core.Abstractions/debug/ZB.MOM.WW.OtOpcUa.Core.Abstractions.dll + ZB.MOM.WW.OtOpcUa.Driver.Modbus.Addressing -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Addressing/debug/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Addressing.dll + ZB.MOM.WW.OtOpcUa.Driver.Ab.Transport -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Ab.Transport/debug/ZB.MOM.WW.OtOpcUa.Driver.Ab.Transport.dll + ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.Heidenhain.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Heidenhain.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.Heidenhain.Contracts.dll + ZB.MOM.WW.OtOpcUa.Core.Scripting.Abstractions -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Core.Scripting.Abstractions/debug/ZB.MOM.WW.OtOpcUa.Core.Scripting.Abstractions.dll + ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.S7.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.S7.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.S7.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.MTConnect.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Contracts.dll + ZB.MOM.WW.OtOpcUa.Commons -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Commons/debug/ZB.MOM.WW.OtOpcUa.Commons.dll + ZB.MOM.WW.OtOpcUa.Driver.Modbus.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Contracts.dll + ZB.MOM.WW.OtOpcUa.Core.AlarmHistorian -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Core.AlarmHistorian/debug/ZB.MOM.WW.OtOpcUa.Core.AlarmHistorian.dll + ZB.MOM.WW.OtOpcUa.Driver.AbCip.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.AbCip.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.AbCip.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Session -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Session/debug/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Session.dll + ZB.MOM.WW.OtOpcUa.Driver.Sql.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Sql.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.Sql.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Transport -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Transport/debug/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Transport.dll + ZB.MOM.WW.OtOpcUa.Driver.Sql.Dialect -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Sql.Dialect/debug/ZB.MOM.WW.OtOpcUa.Driver.Sql.Dialect.dll + ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Browser -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Browser/debug/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Browser.dll + ZB.MOM.WW.OtOpcUa.Core.Scripting -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Core.Scripting/debug/ZB.MOM.WW.OtOpcUa.Core.Scripting.dll + ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Browser -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Browser/debug/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Browser.dll + ZB.MOM.WW.OtOpcUa.Cluster -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Cluster/debug/ZB.MOM.WW.OtOpcUa.Cluster.dll + ZB.MOM.WW.OtOpcUa.Core.VirtualTags -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Core.VirtualTags/debug/ZB.MOM.WW.OtOpcUa.Core.VirtualTags.dll + ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Browser -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Browser/debug/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Browser.dll + ZB.MOM.WW.OtOpcUa.Core.ScriptedAlarms -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Core.ScriptedAlarms/debug/ZB.MOM.WW.OtOpcUa.Core.ScriptedAlarms.dll + ZB.MOM.WW.OtOpcUa.Driver.Sql.Browser -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Sql.Browser/debug/ZB.MOM.WW.OtOpcUa.Driver.Sql.Browser.dll + ZB.MOM.WW.OtOpcUa.Configuration -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Configuration/debug/ZB.MOM.WW.OtOpcUa.Configuration.dll + ZB.MOM.WW.OtOpcUa.Core -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Core/debug/ZB.MOM.WW.OtOpcUa.Core.dll + ZB.MOM.WW.OtOpcUa.Security -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Security/debug/ZB.MOM.WW.OtOpcUa.Security.dll + ZB.MOM.WW.OtOpcUa.Driver.Heidenhain -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Heidenhain/debug/ZB.MOM.WW.OtOpcUa.Driver.Heidenhain.dll + ZB.MOM.WW.OtOpcUa.Driver.Galaxy -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Galaxy/debug/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.dll + ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient/debug/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.dll + ZB.MOM.WW.OtOpcUa.Driver.FOCAS -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.FOCAS/debug/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.dll + ZB.MOM.WW.OtOpcUa.OpcUaServer -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.OpcUaServer/debug/ZB.MOM.WW.OtOpcUa.OpcUaServer.dll + ZB.MOM.WW.OtOpcUa.Driver.AbLegacy -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy/debug/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.dll + ZB.MOM.WW.OtOpcUa.Driver.AbCip -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.AbCip/debug/ZB.MOM.WW.OtOpcUa.Driver.AbCip.dll + ZB.MOM.WW.OtOpcUa.Driver.Sql -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Sql/debug/ZB.MOM.WW.OtOpcUa.Driver.Sql.dll + ZB.MOM.WW.OtOpcUa.Driver.MTConnect -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.MTConnect/debug/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.dll + ZB.MOM.WW.OtOpcUa.ControlPlane -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.ControlPlane/debug/ZB.MOM.WW.OtOpcUa.ControlPlane.dll + ZB.MOM.WW.OtOpcUa.Runtime -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Runtime/debug/ZB.MOM.WW.OtOpcUa.Runtime.dll + ZB.MOM.WW.OtOpcUa.AdminUI -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.AdminUI/debug/ZB.MOM.WW.OtOpcUa.AdminUI.dll + ZB.MOM.WW.OtOpcUa.AdminUI.Tests -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/debug/ZB.MOM.WW.OtOpcUa.AdminUI.Tests.dll +Test run for /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/debug/ZB.MOM.WW.OtOpcUa.AdminUI.Tests.dll (.NETCoreApp,Version=v10.0) +A total of 1 test files matched the specified pattern. +Results File: /Users/dohertj2/Desktop/OtOpcUa/docs/ui-consistency/evidence/ot13-monaco-lifetime/green.trx + +Passed! - Failed: 0, Passed: 30, Skipped: 0, Total: 30, Duration: 511 ms - ZB.MOM.WW.OtOpcUa.AdminUI.Tests.dll (net10.0) diff --git a/docs/ui-consistency/evidence/ot13-monaco-lifetime/green.trx b/docs/ui-consistency/evidence/ot13-monaco-lifetime/green.trx new file mode 100644 index 000000000..ee78ee548 --- /dev/null +++ b/docs/ui-consistency/evidence/ot13-monaco-lifetime/green.trx @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v3.0.2+dd36e86129 (64-bit .NET 10.0.14) +[xUnit.net 00:00:00.27] Discovering: ZB.MOM.WW.OtOpcUa.AdminUI.Tests +[xUnit.net 00:00:00.88] Discovered: ZB.MOM.WW.OtOpcUa.AdminUI.Tests +[xUnit.net 00:00:01.01] Starting: ZB.MOM.WW.OtOpcUa.AdminUI.Tests +[xUnit.net 00:00:01.56] Finished: ZB.MOM.WW.OtOpcUa.AdminUI.Tests + + + + \ No newline at end of file diff --git a/docs/ui-consistency/evidence/ot13-monaco-lifetime/js-green.json b/docs/ui-consistency/evidence/ot13-monaco-lifetime/js-green.json new file mode 100644 index 000000000..f6fc72763 --- /dev/null +++ b/docs/ui-consistency/evidence/ot13-monaco-lifetime/js-green.json @@ -0,0 +1,71 @@ +{ + "boundary": "Actual production MonacoBlazor JS with synthetic Monaco/AMD APIs; no application host or external network", + "scenes": [ + { + "case": "disposed-during-loader", + "effects": { + "created": 0, + "disposed": 0, + "callbacks": 0, + "requests": 0, + "options": [] + }, + "checks": { + "noLateRegistration": true, + "noOrphanDiagnosticRequest": true, + "noRetiredDotNetCallback": true, + "expectedValue": true, + "noPageErrors": true + }, + "errors": [], + "passed": true + }, + { + "case": "detached-during-loader", + "effects": { + "created": 0, + "disposed": 0, + "callbacks": 0, + "requests": 0, + "options": [] + }, + "checks": { + "noLateRegistration": true, + "noOrphanDiagnosticRequest": true, + "noRetiredDotNetCallback": true, + "expectedValue": true, + "noPageErrors": true + }, + "errors": [], + "passed": true + }, + { + "case": "live-control", + "effects": { + "created": 1, + "disposed": 1, + "callbacks": 0, + "requests": 0, + "options": [ + { + "readOnly": true + }, + { + "readOnly": false + } + ] + }, + "checks": { + "noLateRegistration": true, + "noOrphanDiagnosticRequest": true, + "noRetiredDotNetCallback": true, + "expectedValue": true, + "noPageErrors": true, + "existingEditorDisposedOnce": true, + "actualUpdateOptionsForwarding": true + }, + "errors": [], + "passed": true + } + ] +} diff --git a/docs/ui-consistency/evidence/ot13-monaco-lifetime/js-green.log b/docs/ui-consistency/evidence/ot13-monaco-lifetime/js-green.log new file mode 100644 index 000000000..5c12456a6 --- /dev/null +++ b/docs/ui-consistency/evidence/ot13-monaco-lifetime/js-green.log @@ -0,0 +1 @@ +{"scenes": 3, "passed": 3} diff --git a/docs/ui-consistency/evidence/ot13-monaco-lifetime/js-initial-harness-wait.log b/docs/ui-consistency/evidence/ot13-monaco-lifetime/js-initial-harness-wait.log new file mode 100644 index 000000000..1e2575acd --- /dev/null +++ b/docs/ui-consistency/evidence/ot13-monaco-lifetime/js-initial-harness-wait.log @@ -0,0 +1,30 @@ +Traceback (most recent call last): + File "/Users/dohertj2/Desktop/OtOpcUa/infra/tools/ui-consistency/check_monaco_lifetime.py", line 52, in + page.evaluate("window.creation = MonacoBlazor.createEditor('synthetic', document.getElementById('host'), {value:'return 1;',language:'csharp',reportMarkers:true}, dotnet)") + ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/opt/homebrew/lib/python3.14/site-packages/playwright/sync_api/_generated.py", line 8566, in evaluate + self._sync( + ~~~~~~~~~~^ + self._impl_obj.evaluate(expression=expression, arg=mapping.to_impl(arg)) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ) + ^ + File "/opt/homebrew/lib/python3.14/site-packages/playwright/_impl/_sync_base.py", line 115, in _sync + return task.result() + ~~~~~~~~~~~^^ + File "/opt/homebrew/lib/python3.14/site-packages/playwright/_impl/_page.py", line 464, in evaluate + return await self._main_frame.evaluate(expression, arg) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/opt/homebrew/lib/python3.14/site-packages/playwright/_impl/_frame.py", line 320, in evaluate + await self._channel.send( + ...<6 lines>... + ) + File "/opt/homebrew/lib/python3.14/site-packages/playwright/_impl/_connection.py", line 69, in send + return await self._connection.wrap_api_call( + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ...<3 lines>... + ) + ^ + File "/opt/homebrew/lib/python3.14/site-packages/playwright/_impl/_connection.py", line 559, in wrap_api_call + raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None +playwright._impl._errors.Error: Page.evaluate: Event diff --git a/docs/ui-consistency/evidence/ot13-monaco-lifetime/js-initial-loader-origin.log b/docs/ui-consistency/evidence/ot13-monaco-lifetime/js-initial-loader-origin.log new file mode 100644 index 000000000..9f47163a7 --- /dev/null +++ b/docs/ui-consistency/evidence/ot13-monaco-lifetime/js-initial-loader-origin.log @@ -0,0 +1,34 @@ +Traceback (most recent call last): + File "/Users/dohertj2/Desktop/OtOpcUa/infra/tools/ui-consistency/check_monaco_lifetime.py", line 53, in + page.wait_for_function('typeof window.releaseLoader === "function"') + ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/opt/homebrew/lib/python3.14/site-packages/playwright/sync_api/_generated.py", line 11599, in wait_for_function + self._sync( + ~~~~~~~~~~^ + self._impl_obj.wait_for_function( + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ...<4 lines>... + ) + ^ + ) + ^ + File "/opt/homebrew/lib/python3.14/site-packages/playwright/_impl/_sync_base.py", line 113, in _sync + self._dispatcher_fiber.switch() + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ + File "/opt/homebrew/lib/python3.14/site-packages/playwright/sync_api/_context_manager.py", line 56, in greenlet_main + self._loop.run_until_complete(self._connection.run_as_sync()) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/opt/homebrew/Cellar/python@3.14/3.14.3_1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/asyncio/base_events.py", line 706, in run_until_complete + self.run_forever() + ~~~~~~~~~~~~~~~~^^ + File "/opt/homebrew/Cellar/python@3.14/3.14.3_1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/asyncio/base_events.py", line 677, in run_forever + self._run_once() + ~~~~~~~~~~~~~~^^ + File "/opt/homebrew/Cellar/python@3.14/3.14.3_1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/asyncio/base_events.py", line 2008, in _run_once + event_list = self._selector.select(timeout) + File "/opt/homebrew/Cellar/python@3.14/3.14.3_1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/selectors.py", line 548, in select + kev_list = self._selector.control(None, max_ev, timeout) +KeyboardInterrupt +Future exception was never retrieved +future: +playwright._impl._errors.TargetClosedError: Target page, context or browser has been closed diff --git a/docs/ui-consistency/evidence/ot13-monaco-lifetime/js-red.json b/docs/ui-consistency/evidence/ot13-monaco-lifetime/js-red.json new file mode 100644 index 000000000..72b5b66a2 --- /dev/null +++ b/docs/ui-consistency/evidence/ot13-monaco-lifetime/js-red.json @@ -0,0 +1,71 @@ +{ + "boundary": "Actual production MonacoBlazor JS with synthetic Monaco/AMD APIs; no application host or external network", + "scenes": [ + { + "case": "disposed-during-loader", + "effects": { + "created": 1, + "disposed": 0, + "callbacks": 1, + "requests": 1, + "options": [] + }, + "checks": { + "noLateRegistration": false, + "noOrphanDiagnosticRequest": false, + "noRetiredDotNetCallback": false, + "expectedValue": false, + "noPageErrors": true + }, + "errors": [], + "passed": false + }, + { + "case": "detached-during-loader", + "effects": { + "created": 1, + "disposed": 0, + "callbacks": 1, + "requests": 1, + "options": [] + }, + "checks": { + "noLateRegistration": false, + "noOrphanDiagnosticRequest": false, + "noRetiredDotNetCallback": false, + "expectedValue": false, + "noPageErrors": true + }, + "errors": [], + "passed": false + }, + { + "case": "live-control", + "effects": { + "created": 1, + "disposed": 1, + "callbacks": 0, + "requests": 0, + "options": [ + { + "readOnly": true + }, + { + "readOnly": false + } + ] + }, + "checks": { + "noLateRegistration": true, + "noOrphanDiagnosticRequest": true, + "noRetiredDotNetCallback": true, + "expectedValue": true, + "noPageErrors": true, + "existingEditorDisposedOnce": true, + "actualUpdateOptionsForwarding": true + }, + "errors": [], + "passed": true + } + ] +} diff --git a/docs/ui-consistency/evidence/ot13-monaco-lifetime/js-red.log b/docs/ui-consistency/evidence/ot13-monaco-lifetime/js-red.log new file mode 100644 index 000000000..60ad21e6a --- /dev/null +++ b/docs/ui-consistency/evidence/ot13-monaco-lifetime/js-red.log @@ -0,0 +1 @@ +{"scenes": 3, "passed": 1} diff --git a/docs/ui-consistency/evidence/ot13-monaco-lifetime/red.log b/docs/ui-consistency/evidence/ot13-monaco-lifetime/red.log new file mode 100644 index 000000000..aa78f7e38 --- /dev/null +++ b/docs/ui-consistency/evidence/ot13-monaco-lifetime/red.log @@ -0,0 +1,108 @@ + + Determining projects to restore... + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Addressing/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Addressing.csproj (in 45 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Core.Abstractions/ZB.MOM.WW.OtOpcUa.Core.Abstractions.csproj (in 45 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Calculation.Contracts/ZB.MOM.WW.OtOpcUa.Driver.Calculation.Contracts.csproj (in 45 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbCip.Contracts/ZB.MOM.WW.OtOpcUa.Driver.AbCip.Contracts.csproj (in 50 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Contracts/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Contracts.csproj (in 50 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Heidenhain.Contracts/ZB.MOM.WW.OtOpcUa.Driver.Heidenhain.Contracts.csproj (in 0.8 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Ab.Transport/ZB.MOM.WW.OtOpcUa.Driver.Ab.Transport.csproj (in 106 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Contracts/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Contracts.csproj (in 106 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Contracts/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Contracts.csproj (in 36 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Core.Scripting.Abstractions/ZB.MOM.WW.OtOpcUa.Core.Scripting.Abstractions.csproj (in 1 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Core.AlarmHistorian/ZB.MOM.WW.OtOpcUa.Core.AlarmHistorian.csproj (in 123 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Browser/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Browser.csproj (in 124 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Browser/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Browser.csproj (in 53 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.S7.Contracts/ZB.MOM.WW.OtOpcUa.Driver.S7.Contracts.csproj (in 4 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Core.Scripting/ZB.MOM.WW.OtOpcUa.Core.Scripting.csproj (in 59 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Core.ScriptedAlarms/ZB.MOM.WW.OtOpcUa.Core.ScriptedAlarms.csproj (in 133 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Core.VirtualTags/ZB.MOM.WW.OtOpcUa.Core.VirtualTags.csproj (in 62 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Sql.Contracts/ZB.MOM.WW.OtOpcUa.Driver.Sql.Contracts.csproj (in 1 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Commons/ZB.MOM.WW.OtOpcUa.Commons.csproj (in 1 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Contracts/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Contracts.csproj (in 0.6 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Tooling/ZB.MOM.WW.OtOpcUa.Analyzers/ZB.MOM.WW.OtOpcUa.Analyzers.csproj (in 43 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Browser/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Browser.csproj (in 153 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Cluster/ZB.MOM.WW.OtOpcUa.Cluster.csproj (in 155 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts.csproj (in 5 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Sql.Dialect/ZB.MOM.WW.OtOpcUa.Driver.Sql.Dialect.csproj (in 23 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Sql.Browser/ZB.MOM.WW.OtOpcUa.Driver.Sql.Browser.csproj (in 43 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Galaxy/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.csproj (in 164 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.csproj (in 13 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.csproj (in 43 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Sql/ZB.MOM.WW.OtOpcUa.Driver.Sql.csproj (in 40 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.csproj (in 19 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Core/ZB.MOM.WW.OtOpcUa.Core.csproj (in 175 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Heidenhain/ZB.MOM.WW.OtOpcUa.Driver.Heidenhain.csproj (in 105 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbCip/ZB.MOM.WW.OtOpcUa.Driver.AbCip.csproj (in 14 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Session/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Session.csproj (in 2 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Contracts/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Contracts.csproj (in 4 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Transport/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Transport.csproj (in 4 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Contracts/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Contracts.csproj (in 0.6 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.Contracts/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.Contracts.csproj (in 4 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.MTConnect/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.csproj (in 7 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/ZB.MOM.WW.OtOpcUa.OpcUaServer.csproj (in 10 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/ZB.MOM.WW.OtOpcUa.Runtime.csproj (in 21 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Server/ZB.MOM.WW.OtOpcUa.Security/ZB.MOM.WW.OtOpcUa.Security.csproj (in 29 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Server/ZB.MOM.WW.OtOpcUa.ControlPlane/ZB.MOM.WW.OtOpcUa.ControlPlane.csproj (in 10 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Configuration/ZB.MOM.WW.OtOpcUa.Configuration.csproj (in 69 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/ZB.MOM.WW.OtOpcUa.AdminUI.csproj (in 24 ms). + Restored /Users/dohertj2/Desktop/OtOpcUa/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/ZB.MOM.WW.OtOpcUa.AdminUI.Tests.csproj (in 138 ms). + ZB.MOM.WW.OtOpcUa.Analyzers -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Analyzers/debug/ZB.MOM.WW.OtOpcUa.Analyzers.dll + ZB.MOM.WW.OtOpcUa.Driver.Calculation.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Calculation.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.Calculation.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.Modbus.Addressing -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Addressing/debug/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Addressing.dll + ZB.MOM.WW.OtOpcUa.Driver.Ab.Transport -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Ab.Transport/debug/ZB.MOM.WW.OtOpcUa.Driver.Ab.Transport.dll + ZB.MOM.WW.OtOpcUa.Core.Abstractions -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Core.Abstractions/debug/ZB.MOM.WW.OtOpcUa.Core.Abstractions.dll + ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.S7.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.S7.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.S7.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.Heidenhain.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Heidenhain.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.Heidenhain.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.Modbus.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.AbCip.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.AbCip.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.AbCip.Contracts.dll + ZB.MOM.WW.OtOpcUa.Core.Scripting.Abstractions -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Core.Scripting.Abstractions/debug/ZB.MOM.WW.OtOpcUa.Core.Scripting.Abstractions.dll + ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.Sql.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Sql.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.Sql.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Contracts.dll + ZB.MOM.WW.OtOpcUa.Core.AlarmHistorian -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Core.AlarmHistorian/debug/ZB.MOM.WW.OtOpcUa.Core.AlarmHistorian.dll + ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Transport -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Transport/debug/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Transport.dll + ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Session -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Session/debug/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Session.dll + ZB.MOM.WW.OtOpcUa.Commons -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Commons/debug/ZB.MOM.WW.OtOpcUa.Commons.dll + ZB.MOM.WW.OtOpcUa.Driver.MTConnect.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.Contracts/debug/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.Contracts.dll + ZB.MOM.WW.OtOpcUa.Driver.Sql.Dialect -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Sql.Dialect/debug/ZB.MOM.WW.OtOpcUa.Driver.Sql.Dialect.dll + ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Browser -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Browser/debug/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Browser.dll + ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Browser -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Browser/debug/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Browser.dll + ZB.MOM.WW.OtOpcUa.Cluster -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Cluster/debug/ZB.MOM.WW.OtOpcUa.Cluster.dll + ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Browser -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Browser/debug/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Browser.dll + ZB.MOM.WW.OtOpcUa.Driver.Sql.Browser -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Sql.Browser/debug/ZB.MOM.WW.OtOpcUa.Driver.Sql.Browser.dll + ZB.MOM.WW.OtOpcUa.Core.Scripting -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Core.Scripting/debug/ZB.MOM.WW.OtOpcUa.Core.Scripting.dll + ZB.MOM.WW.OtOpcUa.Core.VirtualTags -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Core.VirtualTags/debug/ZB.MOM.WW.OtOpcUa.Core.VirtualTags.dll + ZB.MOM.WW.OtOpcUa.Core.ScriptedAlarms -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Core.ScriptedAlarms/debug/ZB.MOM.WW.OtOpcUa.Core.ScriptedAlarms.dll + ZB.MOM.WW.OtOpcUa.Configuration -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Configuration/debug/ZB.MOM.WW.OtOpcUa.Configuration.dll + ZB.MOM.WW.OtOpcUa.Core -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Core/debug/ZB.MOM.WW.OtOpcUa.Core.dll + ZB.MOM.WW.OtOpcUa.Security -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Security/debug/ZB.MOM.WW.OtOpcUa.Security.dll + ZB.MOM.WW.OtOpcUa.OpcUaServer -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.OpcUaServer/debug/ZB.MOM.WW.OtOpcUa.OpcUaServer.dll + ZB.MOM.WW.OtOpcUa.ControlPlane -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.ControlPlane/debug/ZB.MOM.WW.OtOpcUa.ControlPlane.dll + ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient/debug/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.dll + ZB.MOM.WW.OtOpcUa.Driver.Heidenhain -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Heidenhain/debug/ZB.MOM.WW.OtOpcUa.Driver.Heidenhain.dll + ZB.MOM.WW.OtOpcUa.Driver.AbCip -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.AbCip/debug/ZB.MOM.WW.OtOpcUa.Driver.AbCip.dll + ZB.MOM.WW.OtOpcUa.Driver.Galaxy -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Galaxy/debug/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.dll + ZB.MOM.WW.OtOpcUa.Driver.Sql -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.Sql/debug/ZB.MOM.WW.OtOpcUa.Driver.Sql.dll + ZB.MOM.WW.OtOpcUa.Driver.MTConnect -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.MTConnect/debug/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.dll + ZB.MOM.WW.OtOpcUa.Driver.AbLegacy -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy/debug/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.dll + ZB.MOM.WW.OtOpcUa.Driver.FOCAS -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Driver.FOCAS/debug/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.dll + ZB.MOM.WW.OtOpcUa.Runtime -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.Runtime/debug/ZB.MOM.WW.OtOpcUa.Runtime.dll + ZB.MOM.WW.OtOpcUa.AdminUI -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.AdminUI/debug/ZB.MOM.WW.OtOpcUa.AdminUI.dll + ZB.MOM.WW.OtOpcUa.AdminUI.Tests -> /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/debug/ZB.MOM.WW.OtOpcUa.AdminUI.Tests.dll +Test run for /Users/dohertj2/Desktop/OtOpcUa/artifacts/ot13-monaco-lifetime/bin/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/debug/ZB.MOM.WW.OtOpcUa.AdminUI.Tests.dll (.NETCoreApp,Version=v10.0) +A total of 1 test files matched the specified pattern. +[xUnit.net 00:00:02.78] ZB.MOM.WW.OtOpcUa.AdminUI.Tests.ScriptAnalysis.MonacoCreationLifetimeTests.DisposalDuringCreationCancelsTheAttemptAndDoesNotSynchronizeLaterOptions [FAIL] + Failed ZB.MOM.WW.OtOpcUa.AdminUI.Tests.ScriptAnalysis.MonacoCreationLifetimeTests.DisposalDuringCreationCancelsTheAttemptAndDoesNotSynchronizeLaterOptions [185 ms] + Error Message: + Assert.Single() Failure: The collection was empty + Stack Trace: + at ZB.MOM.WW.OtOpcUa.AdminUI.Tests.ScriptAnalysis.MonacoCreationLifetimeTests.DisposalDuringCreationCancelsTheAttemptAndDoesNotSynchronizeLaterOptions() in /Users/dohertj2/Desktop/OtOpcUa/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/ScriptAnalysis/MonacoCreationLifetimeTests.cs:line 23 +--- End of stack trace from previous location --- +Results File: /Users/dohertj2/Desktop/OtOpcUa/docs/ui-consistency/evidence/ot13-monaco-lifetime/red.trx + +Failed! - Failed: 1, Passed: 0, Skipped: 0, Total: 1, Duration: 197 ms - ZB.MOM.WW.OtOpcUa.AdminUI.Tests.dll (net10.0) diff --git a/docs/ui-consistency/evidence/ot13-monaco-lifetime/red.trx b/docs/ui-consistency/evidence/ot13-monaco-lifetime/red.trx new file mode 100644 index 000000000..8f205e8e2 --- /dev/null +++ b/docs/ui-consistency/evidence/ot13-monaco-lifetime/red.trx @@ -0,0 +1,51 @@ + + + + + + + + + + + Assert.Single() Failure: The collection was empty + at ZB.MOM.WW.OtOpcUa.AdminUI.Tests.ScriptAnalysis.MonacoCreationLifetimeTests.DisposalDuringCreationCancelsTheAttemptAndDoesNotSynchronizeLaterOptions() in /Users/dohertj2/Desktop/OtOpcUa/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/ScriptAnalysis/MonacoCreationLifetimeTests.cs:line 23 +--- End of stack trace from previous location --- + + + + + + + + + + + + + + + + + + + + + [xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v3.0.2+dd36e86129 (64-bit .NET 10.0.14) +[xUnit.net 00:00:00.42] Discovering: ZB.MOM.WW.OtOpcUa.AdminUI.Tests +[xUnit.net 00:00:02.41] Discovered: ZB.MOM.WW.OtOpcUa.AdminUI.Tests +[xUnit.net 00:00:02.54] Starting: ZB.MOM.WW.OtOpcUa.AdminUI.Tests +[xUnit.net 00:00:02.78] Assert.Single() Failure: The collection was empty +[xUnit.net 00:00:02.78] Stack Trace: +[xUnit.net 00:00:02.78] /Users/dohertj2/Desktop/OtOpcUa/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/ScriptAnalysis/MonacoCreationLifetimeTests.cs(23,0): at ZB.MOM.WW.OtOpcUa.AdminUI.Tests.ScriptAnalysis.MonacoCreationLifetimeTests.DisposalDuringCreationCancelsTheAttemptAndDoesNotSynchronizeLaterOptions() +[xUnit.net 00:00:02.78] --- End of stack trace from previous location --- +[xUnit.net 00:00:02.79] Finished: ZB.MOM.WW.OtOpcUa.AdminUI.Tests + + + + + [xUnit.net 00:00:02.78] ZB.MOM.WW.OtOpcUa.AdminUI.Tests.ScriptAnalysis.MonacoCreationLifetimeTests.DisposalDuringCreationCancelsTheAttemptAndDoesNotSynchronizeLaterOptions [FAIL] + + + + \ No newline at end of file diff --git a/infra/tools/ui-consistency/check_monaco_lifetime.py b/infra/tools/ui-consistency/check_monaco_lifetime.py new file mode 100644 index 000000000..c83ba6058 --- /dev/null +++ b/infra/tools/ui-consistency/check_monaco_lifetime.py @@ -0,0 +1,84 @@ +"""Exercise actual shared Monaco JS with deferred AMD loading and synthetic editor APIs. + +No application host, endpoint or network request is used. This proves registration, +option forwarding and timer cleanup, not real Monaco editing or assistive technology. +""" +import argparse +import json +from pathlib import Path +from playwright.sync_api import sync_playwright + +parser = argparse.ArgumentParser() +parser.add_argument('--output', type=Path, required=True) +args = parser.parse_args() +source = Path(__file__).resolve().parents[3] / 'src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/wwwroot/js/monaco-init.js' +setup = """ +window.effects = {created:0, disposed:0, callbacks:0, requests:0, options:[]}; +window.require = function(modules, callback) { window.releaseLoader = callback; }; +window.require.config = function() {}; +window.monaco = { + languages: { + registerCompletionItemProvider(){},registerHoverProvider(){}, + registerDocumentFormattingEditProvider(){},registerSignatureHelpProvider(){} + }, + editor: { + create(host, options) { + effects.created++; + const model = {getValue:()=>options.value}; + return { + getModel:()=>model,getValue:()=>options.value, + onDidChangeModelContent(){},onDidBlurEditorText(){}, + updateOptions(value){effects.options.push(value);}, + dispose(){effects.disposed++;} + }; + },setModelMarkers(){},setTheme(){} + } +}; +window.fetch = async function() {effects.requests++; return {ok:true,json:async()=>({markers:[]})};}; +window.dotnet = {invokeMethodAsync(){effects.callbacks++;return Promise.resolve();}}; +""" +results = [] +with sync_playwright() as p: + browser = p.chromium.launch() + for case in ['disposed-during-loader', 'detached-during-loader', 'live-control']: + page = browser.new_page() + errors = [] + page.on('pageerror', lambda error: errors.append(str(error))) + # Intercept the sole AMD loader request; all data and code remain synthetic/local. + page.route('**/*', lambda route: route.fulfill(status=200, content_type='application/javascript', body='')) + page.set_content('
') + page.evaluate(setup) + page.add_script_tag(content=source.read_text()) + page.evaluate("() => { window.creation = MonacoBlazor.createEditor('synthetic', document.getElementById('host'), {value:'return 1;',language:'csharp',reportMarkers:true}, dotnet); }") + page.wait_for_function('typeof window.releaseLoader === "function"') + if case == 'disposed-during-loader': + page.evaluate("MonacoBlazor.dispose('synthetic')") + elif case == 'detached-during-loader': + page.evaluate("document.getElementById('host').remove()") + page.evaluate('releaseLoader()') + page.evaluate('creation') + if case == 'live-control': + page.evaluate("MonacoBlazor.setEditorOption('synthetic','readOnly',true);MonacoBlazor.setEditorOption('synthetic','readOnly',false)") + value = page.evaluate("MonacoBlazor.getValue('synthetic')") + page.evaluate("MonacoBlazor.dispose('synthetic')") + else: + value = page.evaluate("MonacoBlazor.getValue('synthetic')") + page.wait_for_timeout(550) + effects = page.evaluate('effects') + checks = { + 'noLateRegistration': effects['created'] == (1 if case == 'live-control' else 0), + 'noOrphanDiagnosticRequest': effects['requests'] == 0, + 'noRetiredDotNetCallback': effects['callbacks'] == 0, + 'expectedValue': value == ('return 1;' if case == 'live-control' else None), + 'noPageErrors': not errors, + } + if case == 'live-control': + checks['existingEditorDisposedOnce'] = effects['disposed'] == 1 + checks['actualUpdateOptionsForwarding'] = effects['options'] == [{'readOnly':True},{'readOnly':False}] + results.append({'case':case,'effects':effects,'checks':checks,'errors':errors,'passed':all(checks.values())}) + page.close() + browser.close() +args.output.parent.mkdir(parents=True, exist_ok=True) +args.output.write_text(json.dumps({'boundary':'Actual production MonacoBlazor JS with synthetic Monaco/AMD APIs; no application host or external network', 'scenes':results},indent=2)+'\n') +print(json.dumps({'scenes':len(results),'passed':sum(x['passed'] for x in results)})) +raise SystemExit(0 if all(x['passed'] for x in results) else 1) diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Components/Shared/MonacoEditor.razor b/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Components/Shared/MonacoEditor.razor index 4b804a3f2..dc917ca90 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Components/Shared/MonacoEditor.razor +++ b/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Components/Shared/MonacoEditor.razor @@ -71,6 +71,7 @@ private string AccessibleLabel => string.IsNullOrWhiteSpace(AriaLabel) ? "Code editor" : AriaLabel; private bool _disposed; private bool _initialized; + private bool _initializing; private int _tooLargeBytes; private bool _wrap; private bool _minimap; @@ -78,12 +79,14 @@ protected override async Task OnAfterRenderAsync(bool firstRender) { + if (_disposed) return; if (firstRender) { _dotNetRef = DotNetObjectReference.Create(this); _lastSentValue = Value ?? ""; var createdLabel = AccessibleLabel; var createdReadOnly = ReadOnly; + _initializing = true; try { await JS.InvokeVoidAsync( @@ -103,6 +106,7 @@ maxReportedMessageChars = ScriptEditorLimits.MaxReportedMessageChars }, _dotNetRef); + if (_disposed) return; _initialized = true; _lastSentAriaLabel = createdLabel; _lastSentReadOnly = createdReadOnly; @@ -121,6 +125,7 @@ // A genuine Monaco init failure — surface it instead of hiding it. Logger.LogError(ex, "Monaco editor {EditorId} failed to initialize.", _id); } + finally { _initializing = false; } } else if (_initialized && (Value ?? "") != _lastSentValue) { @@ -258,10 +263,11 @@ public async ValueTask DisposeAsync() { + if (_disposed) return; _disposed = true; try { - if (_initialized) + if (_initialized || _initializing) { try { diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/wwwroot/js/monaco-init.js b/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/wwwroot/js/monaco-init.js index 69abe5202..3d35a9ca2 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/wwwroot/js/monaco-init.js +++ b/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/wwwroot/js/monaco-init.js @@ -1,6 +1,7 @@ (function () { const VS_BASE = "/_content/ZB.MOM.WW.OtOpcUa.AdminUI/lib/monaco/vs"; const editors = {}; + const pendingEditors = new Map(); let readyPromise = null; function ensureLoaded() { @@ -227,8 +228,19 @@ } async function createEditor(id, host, options, dotNetRef) { - await ensureLoaded(); - if (!host) return; + if (!host || !host.isConnected) return; + const creation = {}; + pendingEditors.set(id, creation); + try { await ensureLoaded(); } + catch (error) { + if (pendingEditors.get(id) === creation) pendingEditors.delete(id); + throw error; + } + // Disposal can retire an attempt while AMD loading is pending. A disconnected host + // is likewise retired even if its managed cleanup has not reached JavaScript yet. + if (pendingEditors.get(id) !== creation) return; + pendingEditors.delete(id); + if (!host.isConnected) return; const editor = monaco.editor.create(host, { value: options.value || "", language: options.language || "csharp", ariaLabel: typeof options.ariaLabel === "string" && options.ariaLabel.trim() ? options.ariaLabel : "Code editor", @@ -311,6 +323,7 @@ } function setMarkers(id, m) { const e = editors[id]; const model = e && e.editor.getModel(); if (model) monaco.editor.setModelMarkers(model, "otopcua", m || []); } function dispose(id) { + pendingEditors.delete(id); const e = editors[id]; if (!e) return; if (e.diagTimer) clearTimeout(e.diagTimer); if (e.diagAbort) e.diagAbort.abort(); diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/ScriptAnalysis/MonacoCreationLifetimeTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/ScriptAnalysis/MonacoCreationLifetimeTests.cs new file mode 100644 index 000000000..29f6fe76b --- /dev/null +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/ScriptAnalysis/MonacoCreationLifetimeTests.cs @@ -0,0 +1,42 @@ +using Bunit; +using Microsoft.Extensions.DependencyInjection; +using Shouldly; +using Xunit; +using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared; + +namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.ScriptAnalysis; + +/// Retiring an editor during deferred creation cancels its JavaScript registration. +[Trait("Category", "Unit")] +public sealed class MonacoCreationLifetimeTests : BunitContext +{ + [Fact] + public async Task DisposalDuringCreationCancelsTheAttemptAndDoesNotSynchronizeLaterOptions() + { + Services.AddLogging(); + var create = JSInterop.SetupVoid("MonacoBlazor.createEditor", _ => true); + JSInterop.SetupVoid("MonacoBlazor.dispose", _ => true).SetVoidResult(); + var cut = Render(p => p.Add(x => x.AriaLabel, "Retiring source")); + var creation = Assert.Single(JSInterop.Invocations["MonacoBlazor.createEditor"]); + cut.Render(p => p.Add(x => x.ReadOnly, true).Add(x => x.AriaLabel, "Retired source")); + await cut.InvokeAsync(() => cut.Instance.DisposeAsync().AsTask()); + var cancellation = Assert.Single(JSInterop.Invocations["MonacoBlazor.dispose"]); + cancellation.Arguments[0].ShouldBe(creation.Arguments[0]); + create.SetVoidResult(); + await cut.Instance.InitialRenderFinished.Task.WaitAsync(TimeSpan.FromSeconds(10), Xunit.TestContext.Current.CancellationToken); + // A retired editor must remain uninitialized after the actual creation continuation finished. + var read = await cut.InvokeAsync(() => cut.Instance.GetValueAsync()); + read.Ok.ShouldBeTrue(); + JSInterop.Invocations["MonacoBlazor.setEditorOption"].ShouldBeEmpty(); + JSInterop.Invocations["MonacoBlazor.getValue"].ShouldBeEmpty(); + } + private sealed class RecordedEditor : MonacoEditor + { + public TaskCompletionSource InitialRenderFinished { get; } = new(TaskCreationOptions.RunContinuationsAsynchronously); + protected override async Task OnAfterRenderAsync(bool firstRender) + { + try { await base.OnAfterRenderAsync(firstRender); } + finally { if (firstRender) InitialRenderFinished.TrySetResult(); } + } + } +}