ffmpegwasm / ffmpeg.wasm

FFmpeg for browser, powered by WebAssembly
https://ffmpegwasm.netlify.app
MIT License
14.18k stars 831 forks source link

Abort signal received by worker, but the process continues. #719

Closed ArsenicBismuth closed 5 months ago

ArsenicBismuth commented 5 months ago

PR #573 supposedly adds aborting feature. The message is properly received by the worker as we can see in the image below, but the process continues till completion.

The sample code in the PR is also a bit wrong, as we're supposed to call the .abort() in the AbortController itself, not the signal. But nonetheless the worker received the signal properly, but no interruption is being done.

Code:

const abortController = new AbortController();
const signal = abortController.signal;

const commands = ['-i', 'input.webm', 'output.mp4'];
await ffmpeg.exec(commands, undefined, { signal }).catch(err => {
  if (err.name === "AbortError") {
    console.log(err.message) // "`Message # ID was aborted`"
  }
});

// Later on we call
abortController.abort();

image

ArsenicBismuth commented 5 months ago

Or maybe I have misunderstood the functionality?

So the .abort() call itself would cause the .exec() promise to ends early without waiting for it. It doesn't stop the actual FFmpeg worker process.

In that case, it doesn't add a "new feature" per se, and more that you can control your flow better for handling "abort" situation.