Skip to content

🎥 Make videos programmatically with React

`@remotion/cloudrun`: Add type safety to stream variables

anthropic-code-agent[bot]20370ea7fc08
diff --git a/packages/cloudrun/src/api/render-media-on-cloudrun.ts b/packages/cloudrun/src/api/render-media-on-cloudrun.ts
index 2fcecb5f69..4ed90ec9ec 100644
--- a/packages/cloudrun/src/api/render-media-on-cloudrun.ts
+++ b/packages/cloudrun/src/api/render-media-on-cloudrun.ts
@@ -1,3 +1,4 @@
+import type {Readable} from 'stream';
import {
type AudioCodec,
type ChromiumOptions,
@@ -232,7 +233,6 @@ const internalRenderMediaOnCloudrunRaw = async ({
const renderResponse = await new Promise<
RenderMediaOnCloudrunOutput | CloudRunCrashResponse
>((resolve, reject) => {
- // TODO: Add any sort of type safety
let response:
| RenderMediaOnCloudrunOutput
| ErrorResponsePayload
@@ -241,7 +241,7 @@ const internalRenderMediaOnCloudrunRaw = async ({
const startTime = Date.now();
const formattedStartTime = new Date().toISOString();
- const stream: any = postResponse.data;
+ const stream: Readable = postResponse.data as Readable;
let accumulatedChunks = ''; // A buffer to accumulate chunks.
diff --git a/packages/cloudrun/src/api/render-still-on-cloudrun.ts b/packages/cloudrun/src/api/render-still-on-cloudrun.ts
index f23c45d9c0..c3b120a65e 100644
--- a/packages/cloudrun/src/api/render-still-on-cloudrun.ts
+++ b/packages/cloudrun/src/api/render-still-on-cloudrun.ts
@@ -1,3 +1,4 @@
+import type {Readable} from 'stream';
import type {
ChromiumOptions,
StillImageFormat,
@@ -177,7 +178,7 @@ const internalRenderStillOnCloudRun = async ({
const startTime = Date.now();
const formattedStartTime = new Date().toISOString();
- const stream: any = postResponse.data;
+ const stream: Readable = postResponse.data as Readable;
let accumulatedChunks = ''; // A buffer to accumulate chunks.