Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Use

Manav Rathid8821a0d7354
diff --git a/web/packages/new/photos/services/ffmpeg/web.ts b/web/packages/new/photos/services/ffmpeg/web.ts
index a376b5d884..a52e023d4b 100644
--- a/web/packages/new/photos/services/ffmpeg/web.ts
+++ b/web/packages/new/photos/services/ffmpeg/web.ts
@@ -1,6 +1,6 @@
import { newID } from "@/base/id";
import log from "@/base/log";
-import QueueProcessor from "@ente/shared/utils/queueProcessor";
+import { PromiseQueue } from "@/utils/promise";
import { FFmpeg } from "@ffmpeg/ffmpeg";
import {
ffmpegPathPlaceholder,
@@ -12,7 +12,7 @@ import {
let _ffmpeg: Promise<FFmpeg> | undefined;
/** Queue of in-flight requests. */
-const _ffmpegTaskQueue = new QueueProcessor<Uint8Array>();
+const _ffmpegTaskQueue = new PromiseQueue<Uint8Array>();
/**
* Return the shared {@link FFmpeg} instance, lazily creating and loading it if
@@ -57,10 +57,9 @@ export const ffmpegExecWeb = async (
// > "Out of bounds memory access (evaluating 'Module["_malloc"](len)')"
//
// So serialize them using a promise queue.
- const request = _ffmpegTaskQueue.queueUpRequest(() =>
+ return _ffmpegTaskQueue.add(() =>
ffmpegExec(ffmpeg, command, outputFileExtension, blob),
);
- return await request.promise;
};
const ffmpegExec = async (
diff --git a/web/packages/utils/promise.ts b/web/packages/utils/promise.ts
index 07b65b8da0..0463abb0e4 100644
--- a/web/packages/utils/promise.ts
+++ b/web/packages/utils/promise.ts
@@ -131,9 +131,9 @@ export class PromiseQueue<T> {
* instead of the promise itself, {@link add} takes a function that should
* return the promise that we wish to await.
*/
- async add(task: () => Promise<T>) {
+ async add(task: () => Promise<T>): Promise<T> {
let handlers;
- const p = new Promise((...args) => (handlers = args));
+ const p = new Promise<T>((...args) => (handlers = args));
this.q.push({ task, handlers });
if (this.q.length == 1) this.next();
return p;