diff --git a/Sources/NIOEmbedded/AsyncTestingEventLoop.swift b/Sources/NIOEmbedded/AsyncTestingEventLoop.swift index ef0070b1c1..d7101cdb45 100644 --- a/Sources/NIOEmbedded/AsyncTestingEventLoop.swift +++ b/Sources/NIOEmbedded/AsyncTestingEventLoop.swift @@ -146,7 +146,8 @@ public final class NIOAsyncTestingEventLoop: EventLoop, @unchecked Sendable { task: { do { // UnsafeUnchecked is acceptable because we know we're in the loop here. - promise?.assumeIsolatedUnsafeUnchecked().succeed(try task()) + let result = try task() + promise?.assumeIsolatedUnsafeUnchecked().succeed(result) } catch let err { promise?.fail(err) } diff --git a/Tests/NIOPosixTests/EventLoopFutureIsolatedTests.swift b/Tests/NIOPosixTests/EventLoopFutureIsolatedTests.swift index 4b2ec8874f..b856ec5f52 100644 --- a/Tests/NIOPosixTests/EventLoopFutureIsolatedTests.swift +++ b/Tests/NIOPosixTests/EventLoopFutureIsolatedTests.swift @@ -331,13 +331,15 @@ final class EventLoopFutureIsolatedTest: XCTestCase { func _eventLoopIsolated(loop: any EventLoop) throws { let f = loop.flatSubmit { let value = SuperNotSendable() + value.x = 4 // Again, all of these need to close over value. In addition, // many need to return it as well. let isolated = loop.assumeIsolated() XCTAssertIdentical(isolated.nonisolated(), loop) isolated.execute { - XCTAssertEqual(value.x, 5) + XCTAssertEqual(value.x, 4) + value.x = 5 } let firstFuture = isolated.submit { let val = SuperNotSendable()