Skip to content

🎥 Make videos programmatically with React

Update call-lambda.ts

Jonny Burger80d753690284
diff --git a/packages/lambda/src/shared/call-lambda.ts b/packages/lambda/src/shared/call-lambda.ts
index 5452783f94..cec8308aa1 100644
--- a/packages/lambda/src/shared/call-lambda.ts
+++ b/packages/lambda/src/shared/call-lambda.ts
@@ -218,11 +218,13 @@ const callLambdaWithStreamingWithoutRetry = async <
clear();
};
- // @ts-expect-error - We are adding a listener to a global variable
- (globalThis._dumpUnreleasedBuffers as EventEmitter).addListener(
- 'dump-unreleased-buffers',
- dumpBuffers,
- );
+ if (globalThis._dumpUnreleasedBuffers) {
+ // @ts-expect-error - We are adding a listener to a global variable
+ (globalThis._dumpUnreleasedBuffers as EventEmitter).addListener(
+ 'dump-unreleased-buffers',
+ dumpBuffers,
+ );
+ }
const events =
res.EventStream as AsyncIterable<InvokeWithResponseStreamResponseEvent>;
@@ -256,11 +258,13 @@ const callLambdaWithStreamingWithoutRetry = async <
// Don't put a `break` statement here, as it will cause the socket to not properly exit.
}
- // @ts-expect-error - We are adding a listener to a global variable
- (globalThis._dumpUnreleasedBuffers as EventEmitter).removeListener(
- 'dump-unreleased-buffers',
- dumpBuffers,
- );
+ if (globalThis._dumpUnreleasedBuffers) {
+ // @ts-expect-error - We are adding a listener to a global variable
+ (globalThis._dumpUnreleasedBuffers as EventEmitter).removeListener(
+ 'dump-unreleased-buffers',
+ dumpBuffers,
+ );
+ }
clear();
};