Skip to content

Commit fdb23b4

Browse files
committed
internal error when processing notification should not break the server
1 parent 3821de8 commit fdb23b4

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

modules/smithy4sTests/src/test/scala/jsonrpclib/smithy4sinterop/TestServerSpec.scala

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,34 @@ object TestServerSpec extends SimpleIOSuite {
132132
}
133133
}
134134

135+
testRes("internal error when processing notification should not break the server") {
136+
implicit val greetInputEncoder: Encoder[PingInput] = CirceJsonCodec.fromSchema
137+
138+
for {
139+
ref <- SignallingRef[IO, Option[String]](none).toStream
140+
clientSideChannel <- setup(
141+
channel => {
142+
val testClient = ClientStub(TestClient, channel)
143+
AlgebraWrapper(new TestServer[IO] {
144+
override def greet(name: String): IO[GreetOutput] = ???
145+
146+
override def ping(ping: String): IO[Unit] = {
147+
if (ping == "fail") IO.raiseError(new RuntimeException("throwing internal error on demand"))
148+
else testClient.pong("pong")
149+
}
150+
})
151+
},
152+
_ => AlgebraWrapper(new Client(ref))
153+
)
154+
remoteFunction = clientSideChannel.notificationStub[PingInput]("ping")
155+
_ <- remoteFunction(PingInput("fail")).toStream
156+
_ <- remoteFunction(PingInput("ping")).toStream
157+
result <- ref.discrete.dropWhile(_.isEmpty).take(1)
158+
} yield {
159+
expect.same(result, "pong".some)
160+
}
161+
}
162+
135163
testRes("server returns known error") {
136164
implicit val greetInputEncoder: Encoder[GreetInput] = CirceJsonCodec.fromSchema
137165
implicit val greetOutputDecoder: Decoder[GreetOutput] = CirceJsonCodec.fromSchema

0 commit comments

Comments
 (0)