Skip to content

addon.node : support cancelling transcription via AbortSignal - #3909

Open
buxuku wants to merge 1 commit into
ggml-org:masterfrom
buxuku:feature/addon-cancel
Open

buxuku wants to merge 1 commit into
ggml-org:masterfrom
buxuku:feature/addon-cancel

Conversation

@buxuku

@buxuku buxuku commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Once whisper() starts in addon.node, there's no way to stop it. A long movie/audio file can run for tens of minutes, and in a Node/Electron app the only way for the user to cancel is to kill the process. There's no AbortSignal (or equivalent) on the JS side, even though whisper.cpp already has encoder_begin_callback / abort_callback for this.

This adds an optional params.signal that takes a standard AbortSignal. On abort, the addon sets a shared flag that those existing callbacks poll, so computation stops without touching the core library. The promise still resolves (it doesn't reject): result.cancelled is true and result.transcription keeps whatever segments finished before the abort. An already-aborted signal cancels immediately with no segments. Omit signal and behavior is unchanged — existing callers aren't affected.

I hit this in SmartSub: users start a long transcription and then want to cancel from the UI, but the addon had no way to stop mid-flight. Added cancel-example.js covering mid-flight abort, a pre-aborted signal, and a normal run without signal. Built the addon and ran node cancel-example.js on macOS — all three cases passed.

@buxuku
buxuku force-pushed the feature/addon-cancel branch from f040d8c to c8ae48a Compare June 25, 2026 16:02
@buxuku
buxuku force-pushed the feature/addon-cancel branch from b416e62 to 54454be Compare July 24, 2026 05:31
@buxuku
buxuku force-pushed the feature/addon-cancel branch from 54454be to c8a67c5 Compare July 24, 2026 05:39

This branch has not been deployed

No deployments
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.

1 participant