From 3f1548b95240ee429d3d3768b923da4fd3ab56a7 Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 24 Jul 2026 19:48:11 +0200 Subject: [PATCH] fix(net): preserve failed session tick stacks Keep the original exception stack when cleanup succeeds so connected lifecycle failures identify the real packet/event handler instead of the session wrapper. Co-authored-by: Erik Nilsson --- src/AcDream.App/Net/LiveSessionController.cs | 2 ++ tests/AcDream.App.Tests/Net/LiveSessionControllerTests.cs | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/AcDream.App/Net/LiveSessionController.cs b/src/AcDream.App/Net/LiveSessionController.cs index e6ccb422..82bab1ad 100644 --- a/src/AcDream.App/Net/LiveSessionController.cs +++ b/src/AcDream.App/Net/LiveSessionController.cs @@ -342,6 +342,8 @@ internal sealed class LiveSessionController catch (Exception tickError) { Exception error = StopAfterFailure(tickError); + if (ReferenceEquals(error, tickError)) + throw; throw error; } }); diff --git a/tests/AcDream.App.Tests/Net/LiveSessionControllerTests.cs b/tests/AcDream.App.Tests/Net/LiveSessionControllerTests.cs index 4b4539fc..91883825 100644 --- a/tests/AcDream.App.Tests/Net/LiveSessionControllerTests.cs +++ b/tests/AcDream.App.Tests/Net/LiveSessionControllerTests.cs @@ -805,11 +805,16 @@ public sealed class LiveSessionControllerTests controller.Start(LiveOptions(), host); WorldSession session = operations.Sessions[0]; - Assert.Throws(controller.Tick); + InvalidOperationException error = + Assert.Throws(controller.Tick); Assert.False(controller.IsInWorld); Assert.Null(controller.CurrentSession); Assert.Equal(1, operations.DisposeCounts[session]); + Assert.Contains( + $"{nameof(TestOperations)}.{nameof(TestOperations.Tick)}", + error.StackTrace, + StringComparison.Ordinal); } [Fact]