Skip to content

Commit 5c26876

Browse files
authored
Fix totally unnecessary preconditionFailure in PSQLEventsHandler (#481)
1 parent ee669e9 commit 5c26876

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Sources/PostgresNIO/New/PSQLEventsHandler.swift

+1-3
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,8 @@ final class PSQLEventsHandler: ChannelInboundHandler {
6868
case .authenticated:
6969
break
7070
}
71-
case TLSUserEvent.shutdownCompleted:
72-
break
7371
default:
74-
preconditionFailure()
72+
context.fireUserInboundEventTriggered(event)
7573
}
7674
}
7775

Tests/PostgresNIOTests/New/PostgresConnectionTests.swift

+9
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,15 @@ class PostgresConnectionTests: XCTestCase {
416416
}
417417
}
418418

419+
func testWeDontCrashOnUnexpectedChannelEvents() async throws {
420+
let (connection, channel) = try await self.makeTestConnectionWithAsyncTestingChannel()
421+
422+
enum MyEvent {
423+
case pleaseDontCrash
424+
}
425+
channel.pipeline.fireUserInboundEventTriggered(MyEvent.pleaseDontCrash)
426+
}
427+
419428
func testSerialExecutionOfSamePreparedStatement() async throws {
420429
let (connection, channel) = try await self.makeTestConnectionWithAsyncTestingChannel()
421430

0 commit comments

Comments
 (0)