fix(script-runner): #999 K-5 script-worker frames are cut at the frame cap; one oversized evaluation fails alone instead of killing the worker
This commit is contained in:
@@ -659,6 +659,7 @@ internal sealed class WorkerConnection : IAsyncDisposable
|
||||
var pending = new PendingEval(key, request.EvalId, onFinished, _dispatcher);
|
||||
if (softTimeout is { } soft) pending.Arm(soft, hardGrace, OnHardDeadline, WorkerSoftClock);
|
||||
_pending[request.EvalId] = pending;
|
||||
if (RefuseOversized(request, pending)) return pending;
|
||||
var batch = new EvalBatch();
|
||||
batch.Items.Add(request);
|
||||
if (!Send(new Envelope { Eval = batch }) || _exited.Task.IsCompleted)
|
||||
@@ -689,10 +690,12 @@ internal sealed class WorkerConnection : IAsyncDisposable
|
||||
var pending = new PendingEval(item.Key, item.Request.EvalId, item.OnFinished, _dispatcher);
|
||||
pending.Arm(item.SoftTimeout, item.HardGrace, OnHardDeadline, WorkerSoftClock);
|
||||
_pending[item.Request.EvalId] = pending;
|
||||
batch.Items.Add(item.Request);
|
||||
pendings[i] = pending;
|
||||
if (!RefuseOversized(item.Request, pending)) batch.Items.Add(item.Request);
|
||||
}
|
||||
if (items.Count > 0 && (!Send(new Envelope { Eval = batch }) || _exited.Task.IsCompleted))
|
||||
// The writer cuts the batch into frames within the cap (#999 / review K-5); only an item that fits no frame on
|
||||
// its own is refused above.
|
||||
if (batch.Items.Count > 0 && (!Send(new Envelope { Eval = batch }) || _exited.Task.IsCompleted))
|
||||
{
|
||||
foreach (var pending in pendings)
|
||||
if (_pending.TryRemove(pending.EvalId, out _)) pending.Complete(null);
|
||||
@@ -700,6 +703,28 @@ internal sealed class WorkerConnection : IAsyncDisposable
|
||||
return pendings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// #999 / review K-5: an evaluation whose request (its inputs) is too large for any frame fails ALONE, as an
|
||||
/// unsupported-type result, before it reaches the pipe writer — which would otherwise have to refuse the frame,
|
||||
/// fault, and take the worker (and every evaluation in flight on it) down with it.
|
||||
/// </summary>
|
||||
private bool RefuseOversized(EvalRequest request, PendingEval pending)
|
||||
{
|
||||
if (_writer.FitsOneFrame(request)) return false;
|
||||
if (_pending.TryRemove(request.EvalId, out _))
|
||||
pending.Complete(new EvalResult
|
||||
{
|
||||
EvalId = request.EvalId,
|
||||
Error = new ScriptError
|
||||
{
|
||||
Kind = ScriptError.Types.Kind.UnsupportedType,
|
||||
Message = $"the evaluation's inputs are {request.CalculateSize()} bytes encoded, over the " +
|
||||
$"{_writer.MaxFrameBytes}-byte frame cap",
|
||||
},
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The compiled form of <paramref name="key"/> in this worker when it is loaded at <paramref name="sourceHashHex"/>
|
||||
/// with <paramref name="inputPaths"/> and compiled cleanly — the batch fast path, which never waits for a load.
|
||||
|
||||
Reference in New Issue
Block a user