@remotion/renderer 4.0.286 → 4.0.288

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,14 +38,19 @@ const downloadFileWithoutRetries = ({ onProgress, url, to: toFn }) => {
38
38
  };
39
39
  refreshTimeout();
40
40
  let finishEventSent = false;
41
+ let closeConnection = () => undefined;
41
42
  (0, read_file_1.readFile)(url)
42
- .then((res) => {
43
+ .then(({ response, request }) => {
43
44
  var _a, _b;
44
- const contentDisposition = (_a = res.headers['content-disposition']) !== null && _a !== void 0 ? _a : null;
45
- const contentType = (_b = res.headers['content-type']) !== null && _b !== void 0 ? _b : null;
45
+ closeConnection = () => {
46
+ request.destroy();
47
+ response.destroy();
48
+ };
49
+ const contentDisposition = (_a = response.headers['content-disposition']) !== null && _a !== void 0 ? _a : null;
50
+ const contentType = (_b = response.headers['content-type']) !== null && _b !== void 0 ? _b : null;
46
51
  const to = toFn(contentDisposition, contentType);
47
52
  (0, ensure_output_directory_1.ensureOutputDirectory)(to);
48
- const sizeHeader = res.headers['content-length'];
53
+ const sizeHeader = response.headers['content-length'];
49
54
  const totalSize = typeof sizeHeader === 'undefined' ? null : Number(sizeHeader);
50
55
  const writeStream = (0, node_fs_1.createWriteStream)(to);
51
56
  let downloaded = 0;
@@ -67,9 +72,12 @@ const downloadFileWithoutRetries = ({ onProgress, url, to: toFn }) => {
67
72
  return resolveAndFlag({ sizeInBytes: downloaded, to });
68
73
  });
69
74
  writeStream.on('error', (err) => rejectAndFlag(err));
70
- res.on('error', (err) => rejectAndFlag(err));
71
- res.pipe(writeStream).on('error', (err) => rejectAndFlag(err));
72
- res.on('data', (d) => {
75
+ response.on('error', (err) => {
76
+ closeConnection();
77
+ rejectAndFlag(err);
78
+ });
79
+ response.pipe(writeStream).on('error', (err) => rejectAndFlag(err));
80
+ response.on('data', (d) => {
73
81
  refreshTimeout();
74
82
  downloaded += d.length;
75
83
  refreshTimeout();
@@ -83,11 +91,12 @@ const downloadFileWithoutRetries = ({ onProgress, url, to: toFn }) => {
83
91
  finishEventSent = true;
84
92
  }
85
93
  });
86
- res.on('close', () => {
94
+ response.on('close', () => {
87
95
  if (totalSize !== null && downloaded !== totalSize) {
88
96
  rejectAndFlag(new Error(`${incorrectContentLengthToken} ${downloaded} bytes, but expected ${totalSize} bytes from 'Content-Length'.`));
89
97
  }
90
98
  writeStream.close();
99
+ closeConnection();
91
100
  });
92
101
  })
93
102
  .catch((err) => {
@@ -1,2 +1,7 @@
1
1
  import http from 'node:http';
2
- export declare const readFile: (url: string, redirectsSoFar?: number) => Promise<http.IncomingMessage>;
2
+ type NodeRequestAndResponse = {
3
+ request: http.ClientRequest;
4
+ response: http.IncomingMessage;
5
+ };
6
+ export declare const readFile: (url: string, redirectsSoFar?: number) => Promise<NodeRequestAndResponse>;
7
+ export {};
@@ -20,7 +20,7 @@ const getClient = (url) => {
20
20
  const readFileWithoutRedirect = (url) => {
21
21
  return new Promise((resolve, reject) => {
22
22
  const client = getClient(url);
23
- client(url,
23
+ const req = client(url,
24
24
  // Bun 1.1.16 does not support the `headers` option
25
25
  typeof Bun === 'undefined'
26
26
  ? {
@@ -29,8 +29,10 @@ const readFileWithoutRedirect = (url) => {
29
29
  },
30
30
  }
31
31
  : {}, (res) => {
32
- resolve(res);
33
- }).on('error', (err) => {
32
+ resolve({ request: req, response: res });
33
+ });
34
+ req.on('error', (err) => {
35
+ req.destroy();
34
36
  return reject(err);
35
37
  });
36
38
  });
@@ -39,19 +41,23 @@ const readFile = async (url, redirectsSoFar = 0) => {
39
41
  if (redirectsSoFar > 10) {
40
42
  throw new Error(`Too many redirects while downloading ${url}`);
41
43
  }
42
- const file = await readFileWithoutRedirect(url);
43
- if (redirect_status_codes_1.redirectStatusCodes.includes(file.statusCode)) {
44
- if (!file.headers.location) {
45
- throw new Error(`Received a status code ${file.statusCode} but no "Location" header while calling ${file.headers.location}`);
44
+ const { request, response } = await readFileWithoutRedirect(url);
45
+ if (redirect_status_codes_1.redirectStatusCodes.includes(response.statusCode)) {
46
+ if (!response.headers.location) {
47
+ throw new Error(`Received a status code ${response.statusCode} but no "Location" header while calling ${response.headers.location}`);
46
48
  }
47
49
  const { origin } = new URL(url);
48
- const redirectUrl = new URL(file.headers.location, origin).toString();
50
+ const redirectUrl = new URL(response.headers.location, origin).toString();
51
+ request.destroy();
52
+ response.destroy();
49
53
  return (0, exports.readFile)(redirectUrl, redirectsSoFar + 1);
50
54
  }
51
- if (file.statusCode >= 400) {
52
- const body = await tryToObtainBody(file);
55
+ if (response.statusCode >= 400) {
56
+ const body = await tryToObtainBody(response);
57
+ request.destroy();
58
+ response.destroy();
53
59
  throw new Error([
54
- `Received a status code of ${file.statusCode} while downloading file ${url}.`,
60
+ `Received a status code of ${response.statusCode} while downloading file ${url}.`,
55
61
  body ? `The response body was:` : null,
56
62
  body ? `---` : null,
57
63
  body ? body : null,
@@ -60,7 +66,7 @@ const readFile = async (url, redirectsSoFar = 0) => {
60
66
  .filter(truthy_1.truthy)
61
67
  .join('\n'));
62
68
  }
63
- return file;
69
+ return { request, response };
64
70
  };
65
71
  exports.readFile = readFile;
66
72
  const tryToObtainBody = async (file) => {
@@ -419,8 +419,7 @@ var supportedAudioCodecs = {
419
419
  wav: ["pcm-16"]
420
420
  };
421
421
  var _satisfies = supportedAudioCodecs;
422
- if (_satisfies) {
423
- }
422
+ if (_satisfies) {}
424
423
  var cliFlag4 = "audio-codec";
425
424
  var ssrName = "audioCodec";
426
425
  var defaultAudioCodecs = {
@@ -2431,8 +2430,7 @@ var posixNormalize = (path, allowAboveRoot) => {
2431
2430
  code = SLASH;
2432
2431
  }
2433
2432
  if (code === SLASH) {
2434
- if (lastSlash === i - 1 || dots === 1) {
2435
- } else if (lastSlash !== i - 1 && dots === 2) {
2433
+ if (lastSlash === i - 1 || dots === 1) {} else if (lastSlash !== i - 1 && dots === 2) {
2436
2434
  if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== DOT || res.charCodeAt(res.length - 2) !== DOT) {
2437
2435
  if (res.length > 2) {
2438
2436
  const lastSlashIndex = res.lastIndexOf("/");
@@ -464,13 +464,15 @@ var getClient = (url) => {
464
464
  var readFileWithoutRedirect = (url) => {
465
465
  return new Promise((resolve, reject) => {
466
466
  const client = getClient(url);
467
- client(url, typeof Bun === "undefined" ? {
467
+ const req = client(url, typeof Bun === "undefined" ? {
468
468
  headers: {
469
469
  "user-agent": "Mozilla/5.0 (@remotion/renderer - https://remotion.dev)"
470
470
  }
471
471
  } : {}, (res) => {
472
- resolve(res);
473
- }).on("error", (err) => {
472
+ resolve({ request: req, response: res });
473
+ });
474
+ req.on("error", (err) => {
475
+ req.destroy();
474
476
  return reject(err);
475
477
  });
476
478
  });
@@ -479,19 +481,23 @@ var readFile = async (url, redirectsSoFar = 0) => {
479
481
  if (redirectsSoFar > 10) {
480
482
  throw new Error(`Too many redirects while downloading ${url}`);
481
483
  }
482
- const file = await readFileWithoutRedirect(url);
483
- if (redirectStatusCodes.includes(file.statusCode)) {
484
- if (!file.headers.location) {
485
- throw new Error(`Received a status code ${file.statusCode} but no "Location" header while calling ${file.headers.location}`);
484
+ const { request, response } = await readFileWithoutRedirect(url);
485
+ if (redirectStatusCodes.includes(response.statusCode)) {
486
+ if (!response.headers.location) {
487
+ throw new Error(`Received a status code ${response.statusCode} but no "Location" header while calling ${response.headers.location}`);
486
488
  }
487
489
  const { origin } = new URL(url);
488
- const redirectUrl = new URL(file.headers.location, origin).toString();
490
+ const redirectUrl = new URL(response.headers.location, origin).toString();
491
+ request.destroy();
492
+ response.destroy();
489
493
  return readFile(redirectUrl, redirectsSoFar + 1);
490
494
  }
491
- if (file.statusCode >= 400) {
492
- const body = await tryToObtainBody(file);
495
+ if (response.statusCode >= 400) {
496
+ const body = await tryToObtainBody(response);
497
+ request.destroy();
498
+ response.destroy();
493
499
  throw new Error([
494
- `Received a status code of ${file.statusCode} while downloading file ${url}.`,
500
+ `Received a status code of ${response.statusCode} while downloading file ${url}.`,
495
501
  body ? `The response body was:` : null,
496
502
  body ? `---` : null,
497
503
  body ? body : null,
@@ -499,7 +505,7 @@ var readFile = async (url, redirectsSoFar = 0) => {
499
505
  ].filter(truthy).join(`
500
506
  `));
501
507
  }
502
- return file;
508
+ return { request, response };
503
509
  };
504
510
  var tryToObtainBody = async (file) => {
505
511
  const success = new Promise((resolve) => {
@@ -561,12 +567,19 @@ var downloadFileWithoutRetries = ({ onProgress, url, to: toFn }) => {
561
567
  };
562
568
  refreshTimeout();
563
569
  let finishEventSent = false;
564
- readFile(url).then((res) => {
565
- const contentDisposition = res.headers["content-disposition"] ?? null;
566
- const contentType = res.headers["content-type"] ?? null;
570
+ let closeConnection = () => {
571
+ return;
572
+ };
573
+ readFile(url).then(({ response, request }) => {
574
+ closeConnection = () => {
575
+ request.destroy();
576
+ response.destroy();
577
+ };
578
+ const contentDisposition = response.headers["content-disposition"] ?? null;
579
+ const contentType = response.headers["content-type"] ?? null;
567
580
  const to = toFn(contentDisposition, contentType);
568
581
  ensureOutputDirectory(to);
569
- const sizeHeader = res.headers["content-length"];
582
+ const sizeHeader = response.headers["content-length"];
570
583
  const totalSize = typeof sizeHeader === "undefined" ? null : Number(sizeHeader);
571
584
  const writeStream = createWriteStream(to);
572
585
  let downloaded = 0;
@@ -585,9 +598,12 @@ var downloadFileWithoutRetries = ({ onProgress, url, to: toFn }) => {
585
598
  return resolveAndFlag({ sizeInBytes: downloaded, to });
586
599
  });
587
600
  writeStream.on("error", (err) => rejectAndFlag(err));
588
- res.on("error", (err) => rejectAndFlag(err));
589
- res.pipe(writeStream).on("error", (err) => rejectAndFlag(err));
590
- res.on("data", (d) => {
601
+ response.on("error", (err) => {
602
+ closeConnection();
603
+ rejectAndFlag(err);
604
+ });
605
+ response.pipe(writeStream).on("error", (err) => rejectAndFlag(err));
606
+ response.on("data", (d) => {
591
607
  refreshTimeout();
592
608
  downloaded += d.length;
593
609
  refreshTimeout();
@@ -601,11 +617,12 @@ var downloadFileWithoutRetries = ({ onProgress, url, to: toFn }) => {
601
617
  finishEventSent = true;
602
618
  }
603
619
  });
604
- res.on("close", () => {
620
+ response.on("close", () => {
605
621
  if (totalSize !== null && downloaded !== totalSize) {
606
622
  rejectAndFlag(new Error(`${incorrectContentLengthToken} ${downloaded} bytes, but expected ${totalSize} bytes from 'Content-Length'.`));
607
623
  }
608
624
  writeStream.close();
625
+ closeConnection();
609
626
  });
610
627
  }).catch((err) => {
611
628
  rejectAndFlag(err);
@@ -1221,8 +1238,7 @@ async function releaseObject(client, remoteObject) {
1221
1238
  if (!remoteObject.objectId) {
1222
1239
  return;
1223
1240
  }
1224
- await client.send("Runtime.releaseObject", { objectId: remoteObject.objectId }).catch(() => {
1225
- });
1241
+ await client.send("Runtime.releaseObject", { objectId: remoteObject.objectId }).catch(() => {});
1226
1242
  }
1227
1243
  function addEventListener(emitter, eventName, handler) {
1228
1244
  emitter.on(eventName, handler);
@@ -4090,7 +4106,7 @@ function extractSourceMapUrl(fileContents) {
4090
4106
  }
4091
4107
  var getSourceMapFromRemoteUrl = async (url) => {
4092
4108
  if (!url.endsWith(".js.map")) {
4093
- throw new Error(`The URL ${url} does not seem to be a valid source map URL.`);
4109
+ return Promise.reject(new Error(`The URL ${url} does not seem to be a valid source map URL.`));
4094
4110
  }
4095
4111
  const obj = await fetchUrl(url);
4096
4112
  return new SourceMapConsumer(obj);
@@ -4123,16 +4139,22 @@ var getSourceMap = (filePath, fileContents, type) => {
4123
4139
  return getSourceMapFromRemoteUrl(url);
4124
4140
  };
4125
4141
  var fetchUrl = async (url) => {
4126
- const res = await readFile(url);
4142
+ const { request, response } = await readFile(url);
4127
4143
  return new Promise((resolve, reject) => {
4128
4144
  let downloaded = "";
4129
- res.on("data", (d) => {
4145
+ response.on("data", (d) => {
4130
4146
  downloaded += d;
4131
4147
  });
4132
- res.on("end", () => {
4148
+ response.on("end", () => {
4149
+ request.destroy();
4150
+ response.destroy();
4133
4151
  resolve(downloaded);
4134
4152
  });
4135
- res.on("error", (err) => reject(err));
4153
+ response.on("error", (err) => {
4154
+ request.destroy();
4155
+ response.destroy();
4156
+ return reject(err);
4157
+ });
4136
4158
  });
4137
4159
  };
4138
4160
  function getLinesAround(line, count, lines) {
@@ -4654,8 +4676,7 @@ var getDownloadsCacheDir = () => {
4654
4676
  if (fs5.statSync(path7.join(dir, "package.json")).isFile()) {
4655
4677
  break;
4656
4678
  }
4657
- } catch (e) {
4658
- }
4679
+ } catch (e) {}
4659
4680
  const parent = path7.dirname(dir);
4660
4681
  if (dir === parent) {
4661
4682
  dir = undefined;
@@ -14006,8 +14027,7 @@ var pLimit = (concurrency) => {
14006
14027
  resolve2(result);
14007
14028
  try {
14008
14029
  await result;
14009
- } catch {
14010
- }
14030
+ } catch {}
14011
14031
  next();
14012
14032
  };
14013
14033
  const enqueue = (fn, resolve2, ...args) => {
@@ -14915,8 +14935,7 @@ var dontInlineThis = "package.json";
14915
14935
  var packageJsonPath = null;
14916
14936
  try {
14917
14937
  packageJsonPath = __require.resolve("../../" + dontInlineThis);
14918
- } catch {
14919
- }
14938
+ } catch {}
14920
14939
  var packageJson = packageJsonPath && fs12.existsSync(packageJsonPath) ? JSON.parse(fs12.readFileSync(packageJsonPath, "utf-8")) : null;
14921
14940
  var makeDownloadMap = () => {
14922
14941
  const dir = tmpDir(packageJson ? `remotion-v${packageJson.version.replace(/\./g, "-")}-assets` : "remotion-assets");
@@ -15479,8 +15498,7 @@ var serveStatic = async (path18, options) => {
15479
15498
  const maxTries = 10;
15480
15499
  const portConfig = getPortConfig(options.forceIPv4);
15481
15500
  for (let i = 0;i < maxTries; i++) {
15482
- let unlock = () => {
15483
- };
15501
+ let unlock = () => {};
15484
15502
  try {
15485
15503
  selectedPort = await new Promise((resolve2, reject) => {
15486
15504
  getDesiredPort({
@@ -15542,8 +15560,7 @@ var serveStatic = async (path18, options) => {
15542
15560
  throw err;
15543
15561
  }
15544
15562
  const codedError = err;
15545
- if (codedError.code === "EADDRINUSE") {
15546
- } else {
15563
+ if (codedError.code === "EADDRINUSE") {} else {
15547
15564
  throw err;
15548
15565
  }
15549
15566
  }
@@ -16655,8 +16672,7 @@ var posixNormalize = (path19, allowAboveRoot) => {
16655
16672
  code = SLASH;
16656
16673
  }
16657
16674
  if (code === SLASH) {
16658
- if (lastSlash === i - 1 || dots === 1) {
16659
- } else if (lastSlash !== i - 1 && dots === 2) {
16675
+ if (lastSlash === i - 1 || dots === 1) {} else if (lastSlash !== i - 1 && dots === 2) {
16660
16676
  if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== DOT || res.charCodeAt(res.length - 2) !== DOT) {
16661
16677
  if (res.length > 2) {
16662
16678
  const lastSlashIndex = res.lastIndexOf("/");
@@ -16987,8 +17003,7 @@ var supportedAudioCodecs = {
16987
17003
  wav: ["pcm-16"]
16988
17004
  };
16989
17005
  var _satisfies = supportedAudioCodecs;
16990
- if (_satisfies) {
16991
- }
17006
+ if (_satisfies) {}
16992
17007
  var mapAudioCodecToFfmpegAudioCodecName = (audioCodec) => {
16993
17008
  if (audioCodec === "aac") {
16994
17009
  return "libfdk_aac";
@@ -18378,8 +18393,7 @@ var handleBrowserCrash = (instance, logLevel, indent) => {
18378
18393
  replacing = true;
18379
18394
  await _instance.close({ silent: true }).then(() => {
18380
18395
  Log.info({ indent, logLevel }, "Killed previous browser and making new one");
18381
- }).catch(() => {
18382
- });
18396
+ }).catch(() => {});
18383
18397
  const browser = await make();
18384
18398
  _instance = browser;
18385
18399
  await makeNewPages();
@@ -21344,8 +21358,7 @@ var internalRenderMediaRaw = ({
21344
21358
  });
21345
21359
  try {
21346
21360
  stitcherFfmpeg.kill();
21347
- } catch {
21348
- }
21361
+ } catch {}
21349
21362
  return promise.then(() => {
21350
21363
  reject(err);
21351
21364
  });
@@ -22443,8 +22456,7 @@ var combineChunks = (options) => {
22443
22456
  fps: options.fps,
22444
22457
  framesPerChunk: options.framesPerChunk,
22445
22458
  outputLocation: options.outputLocation,
22446
- onProgress: options.onProgress ?? (() => {
22447
- }),
22459
+ onProgress: options.onProgress ?? (() => {}),
22448
22460
  videoFiles: options.videoFiles,
22449
22461
  everyNthFrame: options.everyNthFrame ?? 1,
22450
22462
  frameRange: options.frameRange ?? null,
package/dist/esm/pure.mjs CHANGED
@@ -205,8 +205,7 @@ var posixNormalize = (path, allowAboveRoot) => {
205
205
  code = SLASH;
206
206
  }
207
207
  if (code === SLASH) {
208
- if (lastSlash === i - 1 || dots === 1) {
209
- } else if (lastSlash !== i - 1 && dots === 2) {
208
+ if (lastSlash === i - 1 || dots === 1) {} else if (lastSlash !== i - 1 && dots === 2) {
210
209
  if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== DOT || res.charCodeAt(res.length - 2) !== DOT) {
211
210
  if (res.length > 2) {
212
211
  const lastSlashIndex = res.lastIndexOf("/");
@@ -341,8 +340,7 @@ var supportedAudioCodecs = {
341
340
  wav: ["pcm-16"]
342
341
  };
343
342
  var _satisfies = supportedAudioCodecs;
344
- if (_satisfies) {
345
- }
343
+ if (_satisfies) {}
346
344
  var cliFlag2 = "audio-codec";
347
345
  var ssrName = "audioCodec";
348
346
  var defaultAudioCodecs = {
@@ -1,7 +1,7 @@
1
1
  import type { BasicSourceMapConsumer, IndexedSourceMapConsumer } from 'source-map';
2
2
  import { SourceMapConsumer } from 'source-map';
3
3
  import type { UnsymbolicatedStackFrame } from './parse-browser-error-stack';
4
- export declare const getSourceMapFromRemoteUrl: (url: string) => Promise<BasicSourceMapConsumer | IndexedSourceMapConsumer>;
4
+ export declare const getSourceMapFromRemoteUrl: (url: string) => Promise<IndexedSourceMapConsumer>;
5
5
  type ScriptLine = {
6
6
  lineNumber: number;
7
7
  content: string;
@@ -26,7 +26,7 @@ function extractSourceMapUrl(fileContents) {
26
26
  }
27
27
  const getSourceMapFromRemoteUrl = async (url) => {
28
28
  if (!url.endsWith('.js.map')) {
29
- throw new Error(`The URL ${url} does not seem to be a valid source map URL.`);
29
+ return Promise.reject(new Error(`The URL ${url} does not seem to be a valid source map URL.`));
30
30
  }
31
31
  const obj = await fetchUrl(url);
32
32
  return new source_map_1.SourceMapConsumer(obj);
@@ -62,16 +62,22 @@ const getSourceMap = (filePath, fileContents, type) => {
62
62
  return (0, exports.getSourceMapFromRemoteUrl)(url);
63
63
  };
64
64
  const fetchUrl = async (url) => {
65
- const res = await (0, read_file_1.readFile)(url);
65
+ const { request, response } = await (0, read_file_1.readFile)(url);
66
66
  return new Promise((resolve, reject) => {
67
67
  let downloaded = '';
68
- res.on('data', (d) => {
68
+ response.on('data', (d) => {
69
69
  downloaded += d;
70
70
  });
71
- res.on('end', () => {
71
+ response.on('end', () => {
72
+ request.destroy();
73
+ response.destroy();
72
74
  resolve(downloaded);
73
75
  });
74
- res.on('error', (err) => reject(err));
76
+ response.on('error', (err) => {
77
+ request.destroy();
78
+ response.destroy();
79
+ return reject(err);
80
+ });
75
81
  });
76
82
  };
77
83
  function getLinesAround(line, count, lines) {
@@ -412,8 +412,7 @@ var require_browser = __commonJS((exports, module) => {
412
412
  });
413
413
  args.splice(lastC, 0, c);
414
414
  }
415
- exports.log = console.debug || console.log || (() => {
416
- });
415
+ exports.log = console.debug || console.log || (() => {});
417
416
  function save(namespaces) {
418
417
  try {
419
418
  if (namespaces) {
@@ -421,15 +420,13 @@ var require_browser = __commonJS((exports, module) => {
421
420
  } else {
422
421
  exports.storage.removeItem("debug");
423
422
  }
424
- } catch (error) {
425
- }
423
+ } catch (error) {}
426
424
  }
427
425
  function load() {
428
426
  let r;
429
427
  try {
430
428
  r = exports.storage.getItem("debug");
431
- } catch (error) {
432
- }
429
+ } catch (error) {}
433
430
  if (!r && typeof process !== "undefined" && "env" in process) {
434
431
  r = process.env.DEBUG;
435
432
  }
@@ -438,8 +435,7 @@ var require_browser = __commonJS((exports, module) => {
438
435
  function localstorage() {
439
436
  try {
440
437
  return localStorage;
441
- } catch (error) {
442
- }
438
+ } catch (error) {}
443
439
  }
444
440
  module.exports = require_common()(exports);
445
441
  var { formatters } = module.exports;
@@ -571,8 +567,7 @@ var require_node = __commonJS((exports, module) => {
571
567
  exports.save = save;
572
568
  exports.load = load;
573
569
  exports.useColors = useColors;
574
- exports.destroy = util.deprecate(() => {
575
- }, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
570
+ exports.destroy = util.deprecate(() => {}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
576
571
  exports.colors = [6, 2, 3, 4, 5, 1];
577
572
  try {
578
573
  const supportsColor = require_supports_color();
@@ -656,8 +651,7 @@ var require_node = __commonJS((exports, module) => {
656
651
  221
657
652
  ];
658
653
  }
659
- } catch (error) {
660
- }
654
+ } catch (error) {}
661
655
  exports.inspectOpts = Object.keys(process.env).filter((key) => {
662
656
  return /^debug_/i.test(key);
663
657
  }).reduce((obj, key) => {
@@ -818,8 +812,7 @@ var require_once = __commonJS((exports, module) => {
818
812
  // ../../node_modules/.pnpm/end-of-stream@1.4.4/node_modules/end-of-stream/index.js
819
813
  var require_end_of_stream = __commonJS((exports, module) => {
820
814
  var once = require_once();
821
- var noop = function() {
822
- };
815
+ var noop = function() {};
823
816
  var isRequest = function(stream) {
824
817
  return stream.setHeader && typeof stream.abort === "function";
825
818
  };
@@ -913,8 +906,7 @@ var require_pump = __commonJS((exports, module) => {
913
906
  var once = require_once();
914
907
  var eos = require_end_of_stream();
915
908
  var fs = __require("fs");
916
- var noop = function() {
917
- };
909
+ var noop = function() {};
918
910
  var ancient = /^v?\.0/.test(process.version);
919
911
  var isFn = function(fn) {
920
912
  return typeof fn === "function";
@@ -2207,8 +2199,7 @@ var require_yauzl = __commonJS((exports) => {
2207
2199
  }
2208
2200
  });
2209
2201
  };
2210
- function Entry() {
2211
- }
2202
+ function Entry() {}
2212
2203
  Entry.prototype.getLastModDate = function() {
2213
2204
  return dosDateTimeToDate(this.lastModFileDate, this.lastModFileTime);
2214
2205
  };
@@ -2826,13 +2817,15 @@ var getClient = (url) => {
2826
2817
  var readFileWithoutRedirect = (url) => {
2827
2818
  return new Promise((resolve, reject) => {
2828
2819
  const client = getClient(url);
2829
- client(url, typeof Bun === "undefined" ? {
2820
+ const req = client(url, typeof Bun === "undefined" ? {
2830
2821
  headers: {
2831
2822
  "user-agent": "Mozilla/5.0 (@remotion/renderer - https://remotion.dev)"
2832
2823
  }
2833
2824
  } : {}, (res) => {
2834
- resolve(res);
2835
- }).on("error", (err) => {
2825
+ resolve({ request: req, response: res });
2826
+ });
2827
+ req.on("error", (err) => {
2828
+ req.destroy();
2836
2829
  return reject(err);
2837
2830
  });
2838
2831
  });
@@ -2841,19 +2834,23 @@ var readFile = async (url, redirectsSoFar = 0) => {
2841
2834
  if (redirectsSoFar > 10) {
2842
2835
  throw new Error(`Too many redirects while downloading ${url}`);
2843
2836
  }
2844
- const file = await readFileWithoutRedirect(url);
2845
- if (redirectStatusCodes.includes(file.statusCode)) {
2846
- if (!file.headers.location) {
2847
- throw new Error(`Received a status code ${file.statusCode} but no "Location" header while calling ${file.headers.location}`);
2837
+ const { request, response } = await readFileWithoutRedirect(url);
2838
+ if (redirectStatusCodes.includes(response.statusCode)) {
2839
+ if (!response.headers.location) {
2840
+ throw new Error(`Received a status code ${response.statusCode} but no "Location" header while calling ${response.headers.location}`);
2848
2841
  }
2849
2842
  const { origin } = new URL(url);
2850
- const redirectUrl = new URL(file.headers.location, origin).toString();
2843
+ const redirectUrl = new URL(response.headers.location, origin).toString();
2844
+ request.destroy();
2845
+ response.destroy();
2851
2846
  return readFile(redirectUrl, redirectsSoFar + 1);
2852
2847
  }
2853
- if (file.statusCode >= 400) {
2854
- const body = await tryToObtainBody(file);
2848
+ if (response.statusCode >= 400) {
2849
+ const body = await tryToObtainBody(response);
2850
+ request.destroy();
2851
+ response.destroy();
2855
2852
  throw new Error([
2856
- `Received a status code of ${file.statusCode} while downloading file ${url}.`,
2853
+ `Received a status code of ${response.statusCode} while downloading file ${url}.`,
2857
2854
  body ? `The response body was:` : null,
2858
2855
  body ? `---` : null,
2859
2856
  body ? body : null,
@@ -2861,7 +2858,7 @@ var readFile = async (url, redirectsSoFar = 0) => {
2861
2858
  ].filter(truthy).join(`
2862
2859
  `));
2863
2860
  }
2864
- return file;
2861
+ return { request, response };
2865
2862
  };
2866
2863
  var tryToObtainBody = async (file) => {
2867
2864
  const success = new Promise((resolve) => {
@@ -2923,12 +2920,19 @@ var downloadFileWithoutRetries = ({ onProgress, url, to: toFn }) => {
2923
2920
  };
2924
2921
  refreshTimeout();
2925
2922
  let finishEventSent = false;
2926
- readFile(url).then((res) => {
2927
- const contentDisposition = res.headers["content-disposition"] ?? null;
2928
- const contentType = res.headers["content-type"] ?? null;
2923
+ let closeConnection = () => {
2924
+ return;
2925
+ };
2926
+ readFile(url).then(({ response, request }) => {
2927
+ closeConnection = () => {
2928
+ request.destroy();
2929
+ response.destroy();
2930
+ };
2931
+ const contentDisposition = response.headers["content-disposition"] ?? null;
2932
+ const contentType = response.headers["content-type"] ?? null;
2929
2933
  const to = toFn(contentDisposition, contentType);
2930
2934
  ensureOutputDirectory(to);
2931
- const sizeHeader = res.headers["content-length"];
2935
+ const sizeHeader = response.headers["content-length"];
2932
2936
  const totalSize = typeof sizeHeader === "undefined" ? null : Number(sizeHeader);
2933
2937
  const writeStream = createWriteStream(to);
2934
2938
  let downloaded = 0;
@@ -2947,9 +2951,12 @@ var downloadFileWithoutRetries = ({ onProgress, url, to: toFn }) => {
2947
2951
  return resolveAndFlag({ sizeInBytes: downloaded, to });
2948
2952
  });
2949
2953
  writeStream.on("error", (err) => rejectAndFlag(err));
2950
- res.on("error", (err) => rejectAndFlag(err));
2951
- res.pipe(writeStream).on("error", (err) => rejectAndFlag(err));
2952
- res.on("data", (d) => {
2954
+ response.on("error", (err) => {
2955
+ closeConnection();
2956
+ rejectAndFlag(err);
2957
+ });
2958
+ response.pipe(writeStream).on("error", (err) => rejectAndFlag(err));
2959
+ response.on("data", (d) => {
2953
2960
  refreshTimeout();
2954
2961
  downloaded += d.length;
2955
2962
  refreshTimeout();
@@ -2963,11 +2970,12 @@ var downloadFileWithoutRetries = ({ onProgress, url, to: toFn }) => {
2963
2970
  finishEventSent = true;
2964
2971
  }
2965
2972
  });
2966
- res.on("close", () => {
2973
+ response.on("close", () => {
2967
2974
  if (totalSize !== null && downloaded !== totalSize) {
2968
2975
  rejectAndFlag(new Error(`${incorrectContentLengthToken} ${downloaded} bytes, but expected ${totalSize} bytes from 'Content-Length'.`));
2969
2976
  }
2970
2977
  writeStream.close();
2978
+ closeConnection();
2971
2979
  });
2972
2980
  }).catch((err) => {
2973
2981
  rejectAndFlag(err);
@@ -3042,8 +3050,7 @@ var getDownloadsCacheDir = () => {
3042
3050
  if (fs2.statSync(path2.join(dir, "package.json")).isFile()) {
3043
3051
  break;
3044
3052
  }
3045
- } catch (e) {
3046
- }
3053
+ } catch (e) {}
3047
3054
  const parent = path2.dirname(dir);
3048
3055
  if (dir === parent) {
3049
3056
  dir = undefined;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/renderer"
4
4
  },
5
5
  "name": "@remotion/renderer",
6
- "version": "4.0.286",
6
+ "version": "4.0.288",
7
7
  "description": "Render Remotion videos using Node.js or Bun",
8
8
  "main": "dist/index.js",
9
9
  "types": "dist/index.d.ts",
@@ -18,8 +18,8 @@
18
18
  "extract-zip": "2.0.1",
19
19
  "source-map": "^0.8.0-beta.0",
20
20
  "ws": "8.17.1",
21
- "remotion": "4.0.286",
22
- "@remotion/streaming": "4.0.286"
21
+ "remotion": "4.0.288",
22
+ "@remotion/streaming": "4.0.288"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "react": ">=16.8.0",
@@ -33,17 +33,17 @@
33
33
  "react-dom": "19.0.0",
34
34
  "@types/ws": "8.5.10",
35
35
  "eslint": "9.19.0",
36
- "@remotion/eslint-config-internal": "4.0.286",
37
- "@remotion/example-videos": "4.0.286"
36
+ "@remotion/example-videos": "4.0.288",
37
+ "@remotion/eslint-config-internal": "4.0.288"
38
38
  },
39
39
  "optionalDependencies": {
40
- "@remotion/compositor-darwin-x64": "4.0.286",
41
- "@remotion/compositor-linux-arm64-gnu": "4.0.286",
42
- "@remotion/compositor-linux-x64-musl": "4.0.286",
43
- "@remotion/compositor-linux-x64-gnu": "4.0.286",
44
- "@remotion/compositor-darwin-arm64": "4.0.286",
45
- "@remotion/compositor-win32-x64-msvc": "4.0.286",
46
- "@remotion/compositor-linux-arm64-musl": "4.0.286"
40
+ "@remotion/compositor-darwin-arm64": "4.0.288",
41
+ "@remotion/compositor-linux-arm64-gnu": "4.0.288",
42
+ "@remotion/compositor-linux-arm64-musl": "4.0.288",
43
+ "@remotion/compositor-linux-x64-gnu": "4.0.288",
44
+ "@remotion/compositor-linux-x64-musl": "4.0.288",
45
+ "@remotion/compositor-win32-x64-msvc": "4.0.288",
46
+ "@remotion/compositor-darwin-x64": "4.0.288"
47
47
  },
48
48
  "keywords": [
49
49
  "remotion",