|
16 | 16 | using System.Threading.Tasks.Dataflow;
|
17 | 17 | using Google.Protobuf.Collections;
|
18 | 18 | using Google.Protobuf.WellKnownTypes;
|
| 19 | +using Microsoft.Azure.WebJobs.Host; |
19 | 20 | using Microsoft.Azure.WebJobs.Logging;
|
20 | 21 | using Microsoft.Azure.WebJobs.Script.Config;
|
21 | 22 | using Microsoft.Azure.WebJobs.Script.Description;
|
22 | 23 | using Microsoft.Azure.WebJobs.Script.Diagnostics;
|
23 | 24 | using Microsoft.Azure.WebJobs.Script.Diagnostics.OpenTelemetry;
|
24 | 25 | using Microsoft.Azure.WebJobs.Script.Eventing;
|
| 26 | +using Microsoft.Azure.WebJobs.Script.Exceptions; |
25 | 27 | using Microsoft.Azure.WebJobs.Script.Extensions;
|
26 | 28 | using Microsoft.Azure.WebJobs.Script.Grpc.Eventing;
|
27 | 29 | using Microsoft.Azure.WebJobs.Script.Grpc.Extensions;
|
@@ -1552,21 +1554,22 @@ public bool IsExecutingInvocation(string invocationId)
|
1552 | 1554 | return _executingInvocations.ContainsKey(invocationId);
|
1553 | 1555 | }
|
1554 | 1556 |
|
1555 |
| - public bool TryFailExecutions(Exception workerException) |
| 1557 | + public void Shutdown(Exception workerException) |
1556 | 1558 | {
|
1557 |
| - if (workerException == null) |
| 1559 | + var shutdownException = workerException; |
| 1560 | + |
| 1561 | + if (workerException is null || workerException is FunctionTimeoutException) |
1558 | 1562 | {
|
1559 |
| - return false; |
| 1563 | + shutdownException = new FunctionTimeoutAbortException(workerException?.Message ?? "Worker channel is shutting down. Aborting function.", workerException); |
1560 | 1564 | }
|
1561 | 1565 |
|
1562 | 1566 | foreach (var invocation in _executingInvocations?.Values)
|
1563 | 1567 | {
|
1564 | 1568 | string invocationId = invocation.Context?.ExecutionContext?.InvocationId.ToString();
|
1565 | 1569 | _workerChannelLogger.LogDebug("Worker '{workerId}' encountered a fatal error. Failing invocation: '{invocationId}'", _workerId, invocationId);
|
1566 |
| - invocation.Context?.SetException(workerException); |
| 1570 | + invocation.Context?.SetException(shutdownException); |
1567 | 1571 | RemoveExecutingInvocation(invocationId);
|
1568 | 1572 | }
|
1569 |
| - return true; |
1570 | 1573 | }
|
1571 | 1574 |
|
1572 | 1575 | /// <summary>
|
|
0 commit comments