Skip to content

Conversation

@abernier
Copy link
Contributor

@abernier abernier commented Sep 5, 2023

const { signal } = new AbortController()

ffmpeg.exec(cmd, undefined, { signal }).catch(err => {
  if (err.name === "AbortError") {
    console.log(err.message) // "`Message # ID was aborted`"
  }
})

// later, change your mind...
signal.abort()

NB: err is a DOMException when aborting

@netlify
Copy link

netlify bot commented Sep 5, 2023

Deploy Preview for ffmpegwasm canceled.

Name Link
🔨 Latest commit 7c6107a
🔍 Latest deploy log https://app.netlify.com/sites/ffmpegwasm/deploys/64f7a447fc736e0008311577

@abernier abernier mentioned this pull request Sep 5, 2023
Copy link
Contributor Author

@abernier abernier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

annotating

{ type, data }: Message,
trans: Transferable[] = []
trans: Transferable[] = [],
signal?: AbortSignal
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a 3rd (optional) param

public load = (config: FFMessageLoadConfig = {}): Promise<IsFirst> => {
public load = (
config: FFMessageLoadConfig = {},
{ signal }: FFMessageOptions = {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for every methods using #send : add an options param to pass the optional signal

data: config,
},
undefined,
signal
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass the signal option to #send

@jeromewu
Copy link
Collaborator

jeromewu commented Oct 9, 2023

LGTM, thanks!

@jeromewu jeromewu merged commit efaae60 into ffmpegwasm:main Oct 9, 2023
@yuedud
Copy link

yuedud commented Mar 5, 2024

hello, when i exec after use abort()
it cant end.
image

@marchaddad123
Copy link

I can confirm having the same issue, after using controller.abort(), the previous executed command still on going.

@luyaocode
Copy link

It doesn't work on my react app.

@risalfajar
Copy link

risalfajar commented Jun 10, 2024

This doesn't end the exec command, but just ending the Promise.

I think #719 should not be closed @ArsenicBismuth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants