File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -291,8 +291,8 @@ export class GenericHandler implements RestateHandler {
291
291
( bytes ) => {
292
292
coreVm . sys_write_output_success ( bytes ) ;
293
293
coreVm . sys_end ( ) ;
294
- } ,
295
- ( e ) => {
294
+ } )
295
+ . catch ( ( e ) => {
296
296
const error = ensureError ( e ) ;
297
297
console . warn ( "Function completed with an error.\n" , error ) ;
298
298
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2023-2024 - Restate Software, Inc., Restate GmbH
3
+ *
4
+ * This file is part of the Restate SDK for Node.js/TypeScript,
5
+ * which is released under the MIT license.
6
+ *
7
+ * You can find a copy of the license in file LICENSE in the root
8
+ * directory of this repository or package, or at
9
+ * https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
10
+ */
11
+
12
+ // Like https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
13
+ // (not yet available in node)
14
+ export class CompletablePromise < T > {
15
+ private success ! : ( value : T | PromiseLike < T > ) => void ;
16
+ private failure ! : ( reason ?: unknown ) => void ;
17
+
18
+ public readonly promise : Promise < T > ;
19
+
20
+ constructor ( ) {
21
+ this . promise = new Promise ( ( resolve , reject ) => {
22
+ this . success = resolve ;
23
+ this . failure = reject ;
24
+ } ) ;
25
+ }
26
+
27
+ public resolve ( value : T ) {
28
+ this . success ( value ) ;
29
+ }
30
+
31
+ public reject ( reason ?: unknown ) {
32
+ this . failure ( reason ) ;
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments