@@ -172,15 +172,20 @@ class ProgramInterpreter {
172172 break ;
173173 }
174174 case CommandType . RECOVER_TERMINAL_MAYBE_UN_AWAITED : {
175- const promise = ctx . serviceClient ( Service ) . terminalFailure ( ) ;
175+ const promise = ctx
176+ . serviceClient ( Service )
177+ . terminalFailure ( )
178+ . map ( ( _v , f ) => {
179+ if ( f ) {
180+ return "terminal" ;
181+ } else {
182+ throw new restate . TerminalError ( "unexpectedly succeeded" ) ;
183+ }
184+ } ) ;
176185 promises . set ( i , {
177- thunk : ( ) => promise . catch ( ( ) => "terminal" ) ,
186+ thunk : ( ) => promise ,
178187 expected : "terminal" ,
179188 } ) ;
180- // failed and unchained promises in Node will cause the process to exit.
181- promise . catch ( ( ) => {
182- /* safety */
183- } ) ;
184189 break ;
185190 }
186191 case CommandType . THROWING_SIDE_EFFECT : {
@@ -232,14 +237,17 @@ class ProgramInterpreter {
232237 }
233238 case CommandType . REJECT_AWAKEABLE : {
234239 const { id, promise } = ctx . awakeable < string > ( ) ;
240+ const mapped = promise . map ( ( _v , f ) => {
241+ if ( f ) {
242+ return "rejected" ;
243+ } else {
244+ throw new restate . TerminalError ( "unexpectedly succeeded" ) ;
245+ }
246+ } ) ;
235247 promises . set ( i , {
236- thunk : ( ) => promise . catch ( ( ) => "rejected" ) ,
248+ thunk : ( ) => mapped ,
237249 expected : "rejected" ,
238250 } ) ;
239- // failed and unchained promises in Node will cause the process to exit.
240- promise . catch ( ( ) => {
241- /* safety */
242- } ) ;
243251 ctx . serviceSendClient ( Service ) . rejectAwakeable ( id ) ;
244252 break ;
245253 }
@@ -267,7 +275,7 @@ class ProgramInterpreter {
267275 promises . set ( i , { thunk : ( ) => promise } ) ;
268276 // safety: we must at least add a catch handler otherwise if the call results with a terminal exception propagated
269277 // and Node will cause this process to exit.
270- promise . catch ( ( ) => { } ) ;
278+ // promise.catch(() => {});
271279 break ;
272280 }
273281 }
0 commit comments