fix(site-runtime): watchdog follows the run across awaits; only the run's own deadline is a timeout (SRT-1, SRT-10, WP3 task 3.6)
This commit is contained in:
@@ -614,7 +614,7 @@ Scripts execute **in-process** with constrained access. The following restrictio
|
|||||||
|
|
||||||
- **Allowed**: Access to the Script Runtime API (GetAttribute, SetAttribute, CallScript, CallShared, ExternalSystem, Notify, Database, Tracking, Alarms, Log), standard C# language features, basic .NET types (collections, string manipulation, math, date/time). `System.Diagnostics.Stopwatch`, `Debug`, and `Activity` are permitted.
|
- **Allowed**: Access to the Script Runtime API (GetAttribute, SetAttribute, CallScript, CallShared, ExternalSystem, Notify, Database, Tracking, Alarms, Log), standard C# language features, basic .NET types (collections, string manipulation, math, date/time). `System.Diagnostics.Stopwatch`, `Debug`, and `Activity` are permitted.
|
||||||
- **Forbidden**: File system access (`System.IO`), process spawning (`System.Diagnostics.Process`), threading (`System.Threading` — except `Tasks`, `CancellationToken`, and `CancellationTokenSource`), reflection (`System.Reflection`), all raw network access (`System.Net` — must use `ExternalSystem.Call`), native interop (`System.Runtime.InteropServices`, `Microsoft.Win32`), assembly loading, unsafe code, `dynamic`, `Activator`.
|
- **Forbidden**: File system access (`System.IO`), process spawning (`System.Diagnostics.Process`), threading (`System.Threading` — except `Tasks`, `CancellationToken`, and `CancellationTokenSource`), reflection (`System.Reflection`), all raw network access (`System.Net` — must use `ExternalSystem.Call`), native interop (`System.Runtime.InteropServices`, `Microsoft.Win32`), assembly loading, unsafe code, `dynamic`, `Activator`.
|
||||||
- **Execution timeout**: Configurable per-script maximum execution time, **measured from enqueue** (WP3.1) — a run that spends its whole budget queued behind blocked scripts is shed at dequeue without executing, rather than being granted a fresh full budget for work whose triggering condition is already stale. Exceeding the timeout cancels the script **cooperatively** (S2/UA5): a script blocked in synchronous I/O or a tight CPU loop does not observe cancellation and continues to occupy its dedicated script-execution thread. A **watchdog names the script** once its thread has not returned within a grace period after the timeout — and, as of WP3.1, **detaches and replaces that worker thread**, so a wedged script costs the pool a thread only until the watchdog fires rather than for the rest of the process. The detached worker exits (instead of pulling more work) when its body finally returns, so capacity never silently doubles. Its slot is then handed back and reused by the next worker start, so a script that wedges on every run does not grow the scheduler's slot table (or start a fresh slot) for the process lifetime. Live detached workers are capped at the pool size — at the cap no replacement is started and an Error site event says so, because bounded starvation is preferable to unbounded thread growth when scripts wedge en masse. The scheduler's **queue depth / busy-thread / oldest-busy-age / detached-thread gauges** and the **per-interval shed count** are reported through Health Monitoring so a saturated, stuck, or shedding scheduler is visible.
|
- **Execution timeout**: Configurable per-script maximum execution time, **measured from enqueue** (WP3.1) — a run that spends its whole budget queued behind blocked scripts is shed at dequeue without executing, rather than being granted a fresh full budget for work whose triggering condition is already stale. Exceeding the timeout cancels the script **cooperatively** (S2/UA5): a script blocked in synchronous I/O or a tight CPU loop does not observe cancellation and continues to occupy its dedicated script-execution thread. A **watchdog names the script** once its thread has not returned within a grace period after the timeout — and, as of WP3.1, **detaches and replaces that worker thread**, so a wedged script costs the pool a thread only until the watchdog fires rather than for the rest of the process. The watchdog detaches the worker the run is blocking **at the moment it fires**, not the one it started on (2026-12-02 review SRT-1): a script's `await` continuation runs on whichever worker dequeues it, under a new run stamp, so the run carries a small tracker in its execution context (`ScriptRunWorkerTracker`, an `AsyncLocal` change callback) that records the current worker each time a piece of the run starts on one — previously a script that had awaited anything before wedging (nearly every real script reads an attribute first) was never detached. Only the run's **own deadline** is reported as a timeout (SRT-10): any other `OperationCanceledException` (an HTTP client's internal timeout, a script's own token) is a failure carrying its real message and stack. The detached worker exits (instead of pulling more work) when its body finally returns, so capacity never silently doubles. Its slot is then handed back and reused by the next worker start, so a script that wedges on every run does not grow the scheduler's slot table (or start a fresh slot) for the process lifetime. Live detached workers are capped at the pool size — at the cap no replacement is started and an Error site event says so, because bounded starvation is preferable to unbounded thread growth when scripts wedge en masse. The scheduler's **queue depth / busy-thread / oldest-busy-age / detached-thread gauges** and the **per-interval shed count** are reported through Health Monitoring so a saturated, stuck, or shedding scheduler is visible.
|
||||||
- **Memory**: Scripts share the host process memory. No per-script memory limit, but the execution timeout prevents runaway allocations.
|
- **Memory**: Scripts share the host process memory. No per-script memory limit, but the execution timeout prevents runaway allocations.
|
||||||
|
|
||||||
The forbidden-API policy is defined authoritatively in `ScriptTrustPolicy` (Script Analysis component, #25). `ScriptCompilationService.ValidateTrustModel` delegates to `ScriptTrustValidator.FindViolations` for the trust verdict; the Site Runtime also performs a `CSharpScript.Compile` against the real `ScriptGlobals` for execution. This is defence-in-depth static enforcement, not a true runtime sandbox.
|
The forbidden-API policy is defined authoritatively in `ScriptTrustPolicy` (Script Analysis component, #25). `ScriptCompilationService.ValidateTrustModel` delegates to `ScriptTrustValidator.FindViolations` for the trust verdict; the Site Runtime also performs a `CSharpScript.Compile` against the real `ScriptGlobals` for execution. This is defence-in-depth static enforcement, not a true runtime sandbox.
|
||||||
|
|||||||
@@ -281,18 +281,16 @@ internal static class ScriptRunLauncher
|
|||||||
var emitPerRunEvents = ScriptRunEventPolicy.ShouldEmitPerRun(effectiveOptions, instanceName, scriptName);
|
var emitPerRunEvents = ScriptRunEventPolicy.ShouldEmitPerRun(effectiveOptions, instanceName, scriptName);
|
||||||
var runStopwatch = Stopwatch.StartNew();
|
var runStopwatch = Stopwatch.StartNew();
|
||||||
|
|
||||||
// Identify the worker this body is holding, so the watchdog can detach and
|
// Track the worker this body is holding — not just in this first segment but after
|
||||||
// replace it if the body wedges. Read in the FIRST synchronous segment — a script
|
// every await (SRT-1): each continuation runs on whichever worker dequeues it, under a
|
||||||
// that later hops threads on an await no longer holds this worker, and the run-stamp
|
// new run stamp, so the watchdog reads the LATEST (slot, stamp) when it fires.
|
||||||
// guard in TryDetachWorker will (correctly) refuse to detach it.
|
var workerTracker = ScriptRunWorkerTracker.Begin(executionScheduler);
|
||||||
var workerSlot = ScriptExecutionScheduler.CurrentWorkerSlot;
|
|
||||||
var workerRunStamp = workerSlot is { } slot ? executionScheduler.CurrentRunStamp(slot) : 0L;
|
|
||||||
|
|
||||||
IDisposable? logScope = null;
|
IDisposable? logScope = null;
|
||||||
var completed = 0;
|
var completed = 0;
|
||||||
ArmStuckScriptWatchdog(
|
ArmStuckScriptWatchdog(
|
||||||
cts, options, logger, siteEventLogger, executionScheduler,
|
cts, options, logger, siteEventLogger, executionScheduler,
|
||||||
workerSlot, workerRunStamp, timeout,
|
workerTracker, timeout,
|
||||||
() => Volatile.Read(ref completed) != 0,
|
() => Volatile.Read(ref completed) != 0,
|
||||||
$"Script '{scriptName}' on instance '{instanceName}'",
|
$"Script '{scriptName}' on instance '{instanceName}'",
|
||||||
instanceName, $"ScriptActor:{scriptName}");
|
instanceName, $"ScriptActor:{scriptName}");
|
||||||
@@ -480,7 +478,11 @@ internal static class ScriptRunLauncher
|
|||||||
// Notify the owning ScriptActor of completion (also releases its in-flight slot).
|
// Notify the owning ScriptActor of completion (also releases its in-flight slot).
|
||||||
completionTarget.Tell(new ScriptActor.ScriptExecutionCompleted(scriptName, true, null));
|
completionTarget.Tell(new ScriptActor.ScriptExecutionCompleted(scriptName, true, null));
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
// Only the run's OWN deadline is a timeout (SRT-10). Any other cancellation — an HTTP
|
||||||
|
// client's internal timeout, a script's own CancellationTokenSource, a cancelled read —
|
||||||
|
// falls through to the general failure path below with its real exception and stack,
|
||||||
|
// instead of being reported as "timed out after N s" for a run that lasted 5 s.
|
||||||
|
catch (OperationCanceledException) when (cts.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
healthCollector?.IncrementScriptError();
|
healthCollector?.IncrementScriptError();
|
||||||
summaryRecorder?.RecordTimedOut(instanceName, scriptName, runStopwatch.ElapsedMilliseconds);
|
summaryRecorder?.RecordTimedOut(instanceName, scriptName, runStopwatch.ElapsedMilliseconds);
|
||||||
@@ -714,18 +716,16 @@ internal static class ScriptRunLauncher
|
|||||||
var scriptName = $"AlarmActor:{alarmName}";
|
var scriptName = $"AlarmActor:{alarmName}";
|
||||||
var runStopwatch = Stopwatch.StartNew();
|
var runStopwatch = Stopwatch.StartNew();
|
||||||
|
|
||||||
// Identify the worker this body is holding, so the
|
// Track the worker this body is holding, so the stuck-script watchdog can detach and
|
||||||
// stuck-script watchdog can detach and replace it if the body wedges — same
|
// replace it if the body wedges — same mechanism, same gauge, as the instance-script
|
||||||
// mechanism, same gauge, as the instance-script path. Read in the FIRST synchronous
|
// path, and likewise followed across awaits (SRT-1).
|
||||||
// segment, before any await.
|
var workerTracker = ScriptRunWorkerTracker.Begin(executionScheduler);
|
||||||
var workerSlot = ScriptExecutionScheduler.CurrentWorkerSlot;
|
|
||||||
var workerRunStamp = workerSlot is { } slot ? executionScheduler.CurrentRunStamp(slot) : 0L;
|
|
||||||
|
|
||||||
IDisposable? logScope = null;
|
IDisposable? logScope = null;
|
||||||
var completed = 0;
|
var completed = 0;
|
||||||
ArmStuckScriptWatchdog(
|
ArmStuckScriptWatchdog(
|
||||||
cts, options, logger, siteEventLogger, executionScheduler,
|
cts, options, logger, siteEventLogger, executionScheduler,
|
||||||
workerSlot, workerRunStamp, timeout,
|
workerTracker, timeout,
|
||||||
() => Volatile.Read(ref completed) != 0,
|
() => Volatile.Read(ref completed) != 0,
|
||||||
$"Alarm on-trigger script for '{alarmName}' on instance '{instanceName}'",
|
$"Alarm on-trigger script for '{alarmName}' on instance '{instanceName}'",
|
||||||
instanceName, scriptName);
|
instanceName, scriptName);
|
||||||
@@ -802,7 +802,8 @@ internal static class ScriptRunLauncher
|
|||||||
summaryRecorder?.RecordCompleted(instanceName, scriptName, runStopwatch.ElapsedMilliseconds);
|
summaryRecorder?.RecordCompleted(instanceName, scriptName, runStopwatch.ElapsedMilliseconds);
|
||||||
completionTarget.Tell(new AlarmActor.AlarmExecutionCompleted(alarmName, true));
|
completionTarget.Tell(new AlarmActor.AlarmExecutionCompleted(alarmName, true));
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
// Only the run's own deadline is a timeout (SRT-10); see RunScriptAsync.
|
||||||
|
catch (OperationCanceledException) when (cts.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
healthCollector?.IncrementScriptError();
|
healthCollector?.IncrementScriptError();
|
||||||
summaryRecorder?.RecordTimedOut(instanceName, scriptName, runStopwatch.ElapsedMilliseconds);
|
summaryRecorder?.RecordTimedOut(instanceName, scriptName, runStopwatch.ElapsedMilliseconds);
|
||||||
@@ -854,8 +855,7 @@ internal static class ScriptRunLauncher
|
|||||||
ILogger logger,
|
ILogger logger,
|
||||||
ISiteEventLogger? siteEventLogger,
|
ISiteEventLogger? siteEventLogger,
|
||||||
ScriptExecutionScheduler scheduler,
|
ScriptExecutionScheduler scheduler,
|
||||||
int? workerSlot,
|
ScriptRunWorkerTracker workerTracker,
|
||||||
long workerRunStamp,
|
|
||||||
TimeSpan timeout,
|
TimeSpan timeout,
|
||||||
Func<bool> isCompleted,
|
Func<bool> isCompleted,
|
||||||
string subject,
|
string subject,
|
||||||
@@ -871,6 +871,8 @@ internal static class ScriptRunLauncher
|
|||||||
var stuckMsg = $"{subject} exceeded its {timeout.TotalSeconds:F0}s timeout and is STILL EXECUTING — " +
|
var stuckMsg = $"{subject} exceeded its {timeout.TotalSeconds:F0}s timeout and is STILL EXECUTING — " +
|
||||||
"its dedicated script-execution thread is blocked (cooperative cancellation not observed).";
|
"its dedicated script-execution thread is blocked (cooperative cancellation not observed).";
|
||||||
|
|
||||||
|
// The worker the run holds NOW — after any number of awaits (SRT-1).
|
||||||
|
var (workerSlot, workerRunStamp) = workerTracker.Snapshot();
|
||||||
var outcome = workerSlot is { } slot
|
var outcome = workerSlot is { } slot
|
||||||
? scheduler.TryDetachWorker(slot, workerRunStamp)
|
? scheduler.TryDetachWorker(slot, workerRunStamp)
|
||||||
: WorkerDetachOutcome.NotRunning;
|
: WorkerDetachOutcome.NotRunning;
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
namespace ZB.MOM.WW.ScadaBridge.SiteRuntime.Scripts;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tracks WHICH script-execution worker a run is holding right now, for the stuck-script
|
||||||
|
/// watchdog (2026-12-02 review SRT-1).
|
||||||
|
/// <para>
|
||||||
|
/// The launcher used to capture <c>(slot, runStamp)</c> once, in the run's first synchronous
|
||||||
|
/// segment. But a script's <c>await</c> continuation is a NEW task queued back onto the scheduler,
|
||||||
|
/// dequeued by whichever worker is free under a NEW run stamp — so once the script had awaited
|
||||||
|
/// anything (practically every script reads an attribute before doing I/O), the watchdog's
|
||||||
|
/// captured pair no longer matched, <c>TryDetachWorker</c> answered <c>NotRunning</c>, and a
|
||||||
|
/// worker wedged in blocking I/O was never detached or replaced.
|
||||||
|
/// </para>
|
||||||
|
/// <para>
|
||||||
|
/// The run's tracker flows with its <see cref="ExecutionContext"/> through an
|
||||||
|
/// <see cref="AsyncLocal{T}"/> whose change callback fires every time a piece of the run starts
|
||||||
|
/// (context restored on a thread) or stops (context reverted) executing. On start it records the
|
||||||
|
/// current thread's worker slot and that worker's current run stamp; on stop it clears them if
|
||||||
|
/// that worker was the recorded one. A run blocked inside a continuation therefore keeps the
|
||||||
|
/// latest <c>(slot, stamp)</c> of the worker it is actually blocking, while a run parked in an
|
||||||
|
/// await (holding no thread) reads as "not on a worker".
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class ScriptRunWorkerTracker
|
||||||
|
{
|
||||||
|
private static readonly AsyncLocal<ScriptRunWorkerTracker?> Current = new(OnContextChanged);
|
||||||
|
|
||||||
|
private readonly ScriptExecutionScheduler _scheduler;
|
||||||
|
private readonly object _gate = new();
|
||||||
|
private int _slot = -1;
|
||||||
|
private long _stamp;
|
||||||
|
|
||||||
|
private ScriptRunWorkerTracker(ScriptExecutionScheduler scheduler) => _scheduler = scheduler;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Starts tracking the calling run: records the worker the caller is on (if any) and installs
|
||||||
|
/// the tracker in the run's execution context so every later continuation updates it. Call in
|
||||||
|
/// the run's first synchronous segment.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="scheduler">The scheduler whose workers run this script.</param>
|
||||||
|
/// <returns>The run's tracker.</returns>
|
||||||
|
public static ScriptRunWorkerTracker Begin(ScriptExecutionScheduler scheduler)
|
||||||
|
{
|
||||||
|
var tracker = new ScriptRunWorkerTracker(scheduler);
|
||||||
|
tracker.OnEnter();
|
||||||
|
Current.Value = tracker;
|
||||||
|
return tracker;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The worker the run is executing on right now, as <c>(slot, runStamp)</c>; a null slot when
|
||||||
|
/// the run holds no script-execution worker (parked in an await, or on another thread).
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The latest observed worker slot and its run stamp.</returns>
|
||||||
|
public (int? Slot, long RunStamp) Snapshot()
|
||||||
|
{
|
||||||
|
lock (_gate)
|
||||||
|
return _slot >= 0 ? (_slot, _stamp) : (null, 0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnContextChanged(AsyncLocalValueChangedArgs<ScriptRunWorkerTracker?> args)
|
||||||
|
{
|
||||||
|
// Only thread switches matter; the explicit set in Begin already recorded the worker.
|
||||||
|
if (!args.ThreadContextChanged)
|
||||||
|
return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (args.PreviousValue is { } leaving && !ReferenceEquals(leaving, args.CurrentValue))
|
||||||
|
leaving.OnLeave();
|
||||||
|
if (args.CurrentValue is { } entering && !ReferenceEquals(entering, args.PreviousValue))
|
||||||
|
entering.OnEnter();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Never let diagnostics bookkeeping fault an execution-context switch.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEnter()
|
||||||
|
{
|
||||||
|
// Only a script-execution worker is recorded. The run's execution context also flows to
|
||||||
|
// threads that hold no worker — a thread-pool continuation, or the watchdog's own
|
||||||
|
// timer callback, which captured the context when it was registered — and those must
|
||||||
|
// NOT erase the worker a still-running segment is blocking. A stale record is harmless:
|
||||||
|
// OnLeave clears it when that worker's segment ends, and TryDetachWorker re-checks the
|
||||||
|
// run stamp before detaching anything.
|
||||||
|
if (ScriptExecutionScheduler.CurrentWorkerSlot is not { } slot)
|
||||||
|
return;
|
||||||
|
var stamp = _scheduler.CurrentRunStamp(slot);
|
||||||
|
if (stamp == 0)
|
||||||
|
return;
|
||||||
|
lock (_gate)
|
||||||
|
{
|
||||||
|
_slot = slot;
|
||||||
|
_stamp = stamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnLeave()
|
||||||
|
{
|
||||||
|
var slot = ScriptExecutionScheduler.CurrentWorkerSlot;
|
||||||
|
lock (_gate)
|
||||||
|
{
|
||||||
|
if (slot is { } s && s == _slot)
|
||||||
|
{
|
||||||
|
_slot = -1;
|
||||||
|
_stamp = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -127,6 +127,67 @@ public class StuckScriptWatchdogTests : TestKit, IDisposable
|
|||||||
Assert.Equal(1, scheduler.MaximumConcurrencyLevel);
|
Assert.Equal(1, scheduler.MaximumConcurrencyLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// SRT-1: a script that AWAITS before it wedges. Its continuation runs on whichever worker
|
||||||
|
/// dequeues it, under a new run stamp, so the (slot, stamp) captured in the first synchronous
|
||||||
|
/// segment no longer matches; pre-fix the watchdog answered NotRunning and never detached the
|
||||||
|
/// worker the continuation was actually blocking. Nearly every real script awaits an attribute
|
||||||
|
/// read before doing its I/O.
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void ScriptWedgedAfterAnAwait_StillDetachesTheWorkerItIsBlocking()
|
||||||
|
{
|
||||||
|
using var scheduler = new ScriptExecutionScheduler(1);
|
||||||
|
var siteLog = new FakeSiteEventLogger();
|
||||||
|
var options = WatchdogOptions();
|
||||||
|
|
||||||
|
var wedged = BuildScriptActor("AwaitThenWedge", CompileRaw(
|
||||||
|
"await Task.Delay(20); " +
|
||||||
|
"ZB.MOM.WW.ScadaBridge.SiteRuntime.Tests.Actors.WatchdogHooks.Gate.Wait(); return null;"),
|
||||||
|
options, scheduler, new SingleServiceProvider(siteLog));
|
||||||
|
wedged.Tell(new ScriptCallRequest("AwaitThenWedge", null, 0, "corr-await"), ActorRefs.NoSender);
|
||||||
|
|
||||||
|
AwaitAssert(
|
||||||
|
() => Assert.Equal(1, scheduler.DetachedThreadCount), // pre-fix: stays 0
|
||||||
|
TimeSpan.FromSeconds(15));
|
||||||
|
AwaitAssert(
|
||||||
|
() => Assert.Contains(siteLog.OfType("script"), r =>
|
||||||
|
r.Message.Contains("AwaitThenWedge") && r.Message.Contains("DETACHED")),
|
||||||
|
TimeSpan.FromSeconds(5));
|
||||||
|
|
||||||
|
// The replacement worker serves new work while the continuation stays wedged.
|
||||||
|
var healthy = BuildScriptActor("HealthyAfterAwait", CompileRaw("return 3;"), options, scheduler, null);
|
||||||
|
var caller = CreateTestProbe();
|
||||||
|
healthy.Tell(new ScriptCallRequest("HealthyAfterAwait", null, 0, "corr-h"), caller.Ref);
|
||||||
|
Assert.True(caller.ExpectMsg<ScriptCallResult>(TimeSpan.FromSeconds(15)).Success);
|
||||||
|
|
||||||
|
WatchdogHooks.Gate.Release();
|
||||||
|
AwaitAssert(() => Assert.Equal(0, scheduler.DetachedThreadCount), TimeSpan.FromSeconds(15));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// SRT-10: a cancellation that is NOT the run's own deadline (an HTTP client's internal
|
||||||
|
/// timeout, a script's own token) is a failure with its real message — not "timed out after
|
||||||
|
/// N s" for a run that never reached its timeout.
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void ForeignCancellation_IsReportedAsAFailure_NotATimeout()
|
||||||
|
{
|
||||||
|
using var scheduler = new ScriptExecutionScheduler(1);
|
||||||
|
var options = new SiteRuntimeOptions { ScriptExecutionTimeoutSeconds = 60, StuckScriptGraceMs = 200, MaxScriptCallDepth = 10 };
|
||||||
|
|
||||||
|
var actor = BuildScriptActor("OwnCancel", CompileRaw(
|
||||||
|
"throw new System.OperationCanceledException(\"upstream request was cancelled\");"),
|
||||||
|
options, scheduler, null);
|
||||||
|
var caller = CreateTestProbe();
|
||||||
|
actor.Tell(new ScriptCallRequest("OwnCancel", null, 0, "corr-cancel"), caller.Ref);
|
||||||
|
|
||||||
|
var result = caller.ExpectMsg<ScriptCallResult>(TimeSpan.FromSeconds(15));
|
||||||
|
Assert.False(result.Success);
|
||||||
|
Assert.DoesNotContain("timed out", result.ErrorMessage); // pre-fix: "timed out after 60s"
|
||||||
|
Assert.Contains("upstream request was cancelled", result.ErrorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Verifies that at the detach cap no further replacement is started and an error event is emitted.</summary>
|
/// <summary>Verifies that at the detach cap no further replacement is started and an error event is emitted.</summary>
|
||||||
[Fact]
|
[Fact]
|
||||||
public void AtTheDetachCap_NoFurtherReplacementIsStarted_AndAnErrorEventIsEmitted()
|
public void AtTheDetachCap_NoFurtherReplacementIsStarted_AndAnErrorEventIsEmitted()
|
||||||
|
|||||||
Reference in New Issue
Block a user