fix(scripting): #1064 the ScriptWorker applies the in-process result rule — a returned lazy sequence is materialised inside the run and held to Scripting:MaxResultElements (Hello.max_result_elements), same value and same failure text in both runners

This commit is contained in:
Joseph Doherty
2026-12-03 16:35:01 -05:00
parent fe4bbbe256
commit a06dc8dd9f
8 changed files with 85 additions and 5 deletions
@@ -764,7 +764,8 @@ public sealed class OutOfProcessScriptRunner : IPhysicalScriptRunner, IAsyncDisp
LoadTimeout: LoadTimeout,
CompileThreads: _compileThreads,
WorkerSid: WorkerSid,
HeartbeatSilenceLimit: _heartbeatSilenceLimit);
HeartbeatSilenceLimit: _heartbeatSilenceLimit,
MaxResultElements: _options.MaxResultElements);
return new WorkerShard(label, isolation,
(onExiting, ct) => WorkerConnection.StartAsync(spec, _log, OnLogs, onExiting, ct),
OnWorkerExit, _log);
@@ -102,6 +102,11 @@ internal sealed record BatchSubmission(string Key, EvalRequest Request, TimeSpan
/// Ask the worker to run the soft clock from each run's start (lmxopcua#827; see <see cref="WorkerConnection.WorkerSoftClock"/>).
/// False (tests only) keeps the pre-#827 host clock, which is also what a worker that does not echo it gets.
/// </param>
/// <param name="MaxResultElements">
/// <c>Scripting:MaxResultElements</c> (lmxopcua#1064): the element cap the worker holds a value script's returned
/// sequence to while materialising it inside the run — the same rule the in-process guard applies (#1059). 0 = the
/// worker's default.
/// </param>
internal sealed record WorkerLaunchSpec(
string Shard,
string WorkerPath,
@@ -117,7 +122,8 @@ internal sealed record WorkerLaunchSpec(
string? WorkerSid = null,
bool WorkerSoftClock = true,
TimeSpan? HeartbeatSilenceLimit = null,
bool TestStallReaderOnDiag = false)
bool TestStallReaderOnDiag = false,
int MaxResultElements = 0)
{
/// <summary>The default compile timeout.</summary>
public static readonly TimeSpan DefaultLoadTimeout = TimeSpan.FromSeconds(60);
@@ -448,6 +454,7 @@ internal sealed class WorkerConnection : IAsyncDisposable
CompileThreads = (uint)Math.Max(0, spec.CompileThreads),
WorkerSoftClock = spec.WorkerSoftClock,
TestStallReaderOnDiag = spec.TestStallReaderOnDiag,
MaxResultElements = (uint)Math.Max(0, spec.MaxResultElements),
};
/// <summary>