Conversation
buxuku
force-pushed
the
feature/addon-cancel
branch
from
June 25, 2026 16:02
f040d8c to
c8ae48a
Compare
buxuku
force-pushed
the
feature/addon-cancel
branch
from
July 24, 2026 05:31
b416e62 to
54454be
Compare
buxuku
force-pushed
the
feature/addon-cancel
branch
from
July 24, 2026 05:39
54454be to
c8a67c5
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.