File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -23,13 +23,12 @@ const RESOLVED: Promise<void> = Promise.resolve();
23
23
export class LambdaConnection implements Connection {
24
24
// Empty buffer to store journal output messages
25
25
private outputBuffer : Buffer = Buffer . alloc ( 0 ) ;
26
- private suspendedOrCompleted = false ;
27
26
28
27
// Callback to resolve the invocation promise of the Lambda handler when the response is ready
29
28
private readonly completionPromise : Promise < Buffer > ;
30
29
private resolveOnCompleted ! : ( value : Buffer | PromiseLike < Buffer > ) => void ;
31
30
32
- constructor ( ) {
31
+ constructor ( private suspendedOrCompleted = false ) {
33
32
// Promise that signals when the invocation is over, to then flush the messages
34
33
this . completionPromise = new Promise < Buffer > ( ( resolve ) => {
35
34
this . resolveOnCompleted = resolve ;
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import { Message } from "../types/types";
28
28
import { StateMachine } from "../state_machine" ;
29
29
import { ensureError } from "../types/errors" ;
30
30
import { KeyedRouter , UnKeyedRouter } from "../public_api" ;
31
+ import { OUTPUT_STREAM_ENTRY_MESSAGE_TYPE } from "../types/protocol" ;
31
32
32
33
/**
33
34
* Creates an Restate entrypoint for services deployed on AWS Lambda and invoked
@@ -223,10 +224,11 @@ export class LambdaRestateServer extends BaseRestateServer {
223
224
let decodedEntries : Message [ ] | null = decodeLambdaBody ( event . body ) ;
224
225
const journalBuilder = new InvocationBuilder ( method ) ;
225
226
decodedEntries . forEach ( ( e : Message ) => journalBuilder . handleMessage ( e ) ) ;
227
+ const alreadyCompleted = decodedEntries . find ( ( e : Message ) => e . messageType === OUTPUT_STREAM_ENTRY_MESSAGE_TYPE ) !== undefined
226
228
decodedEntries = null ;
227
229
228
230
// set up and invoke the state machine
229
- const connection = new LambdaConnection ( ) ;
231
+ const connection = new LambdaConnection ( alreadyCompleted ) ;
230
232
const stateMachine = new StateMachine (
231
233
connection ,
232
234
journalBuilder . build ( ) ,
You can’t perform that action at this time.
0 commit comments