Skip to content
Merged
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
6 changes: 6 additions & 0 deletions .changes/barcode-scanner-cancel-settles-scan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"barcode-scanner": patch
"barcode-scanner-js": patch
---

Fix `cancel()` on Android leaving the pending `scan()` promise unsettled: `destroy()` cleared the saved invoke before it was rejected, so the `"cancelled"` rejection never reached the caller. The pending scan is now rejected before the camera is torn down, matching iOS.
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,10 @@ class BarcodeScannerPlugin(private val activity: Activity) : Plugin(activity),

@Command
fun cancel(invoke: Invoke) {
destroy()
// Reject the pending scan before destroy() clears savedInvoke, otherwise the
// scan() promise is never settled. Mirrors the iOS implementation.
savedInvoke?.reject("cancelled")
destroy()
invoke.resolve()
}

Expand Down
Loading