Runtime exceptions from serializers are not propogated to the calling thread #1287
-
Description I noticed that whenever there is a runtime exception in the custom serializer, the exception is not propagated to the calling thread immediately (the thread that started the ask call) therefore leading to blocking the calling thread for the duration of 20 seconds and therefore leading to AskTimeoutException. Is there a way to fail immediately instead of waiting for the future to timeout ? Example application Stack trace
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I don't have my computer with me so can't fully investigate this. Serialization normally only occurs when you use Pekko Remote or Cluster mode. Are you using either of those? It is an overhead if you don't need it. If you need serialization, why not use pekko-serialization-jackson? If you must write custom serialization, could you throw a https://docs.oracle.com/javase%2F8%2Fdocs%2Fapi%2F%2F/java/io/NotSerializableException.html instead of a RuntimeException. I see this exception mentioned in the Pekko docs. I don't know if this is handled better but it is worth a try. |
Beta Was this translation helpful? Give feedback.
-
If you want the error to response to the origin actor who is asking, then the message need attract with a promise I think, which surely doesn't. |
Beta Was this translation helpful? Give feedback.
Googling, I can't find much discussion about how Akka or Pekko handles failures in serialization. One workaround until someone with more expertise in this area looks into this: catch the exception in your custom serializer and send a serialization of a simple object that flags the serialization issue instead The downstream actor can match on this object and reply with the same message. The ask will then get this as its response. Very circuitous but is a viable workaround until we work out how to handle the issue entirely on the sender side.