Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/ffmpeg/src/classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
FFFSPath,
} from "./types.js";
import { getMessageID } from "./utils.js";
import { ERROR_TERMINATED, ERROR_NOT_LOADED } from "./errors.js";
import { ERROR_TERMINATED, ERROR_NOT_LOADED, ERROR_WORKER } from "./errors.js";

type FFMessageOptions = {
signal?: AbortSignal;
Expand Down Expand Up @@ -87,6 +87,16 @@ export class FFmpeg {
delete this.#resolves[id];
delete this.#rejects[id];
};
this.#worker.onerror = () => {
const rejects = { ...this.#rejects };
this.#rejects = {};
this.#resolves = {};
this.#worker = null;
this.loaded = false;
for (const reject of Object.values(rejects)) {
reject(ERROR_WORKER);
}
};
}
};

Expand Down
3 changes: 3 additions & 0 deletions packages/ffmpeg/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ export const ERROR_TERMINATED = new Error("called FFmpeg.terminate()");
export const ERROR_IMPORT_FAILURE = new Error(
"failed to import ffmpeg-core.js"
);
export const ERROR_WORKER = new Error(
"worker encountered an error, this is most likely caused by the worker script failing to load (CORP, network error, 404, etc.)"
);