Skip to content

Commit 1acc60e

Browse files
Add exception handling during doProgress call in HandlerContextImpl to prevent unhandled errors. This seems to be the cause of so many unhandled suspension exceptions, and possibly the reason for threads left hanging.
1 parent 7591272 commit 1acc60e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

sdk-core/src/main/java/dev/restate/sdk/core/HandlerContextImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,14 @@ private void pollAsyncResultInner(AsyncResultInternal<?> asyncResult) {
399399
}
400400

401401
// Not ready yet, let's try to do some progress
402-
StateMachine.DoProgressResponse response = this.stateMachine.doProgress(uncompletedLeaves);
402+
StateMachine.DoProgressResponse response;
403+
try {
404+
response = this.stateMachine.doProgress(uncompletedLeaves);
405+
} catch (Throwable e) {
406+
this.failWithoutContextSwitch(e);
407+
asyncResult.publicFuture().completeExceptionally(AbortedExecutionException.INSTANCE);
408+
return;
409+
}
403410

404411
if (response instanceof StateMachine.DoProgressResponse.AnyCompleted) {
405412
// Let it loop now

sdk-core/src/main/java/dev/restate/sdk/core/statemachine/StateMachineImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ public void onNext(Slice slice) {
152152

153153
@Override
154154
public void onError(Throwable throwable) {
155-
LOG.trace("Got failure", throwable);
156155
this.stateContext.getCurrentState().hitError(throwable, null, null, this.stateContext);
157156
cancelInputSubscription();
158157
}

0 commit comments

Comments
 (0)