Skip to content

Fix: Prevent double MethodChannel result in Carrot.setup#12

Open
1leary1 wants to merge 1 commit into
carrotquest:masterfrom
1leary1:fix/android-methodchannel-double-response
Open

Fix: Prevent double MethodChannel result in Carrot.setup#12
1leary1 wants to merge 1 commit into
carrotquest:masterfrom
1leary1:fix/android-methodchannel-double-response

Conversation

@1leary1
Copy link
Copy Markdown

@1leary1 1leary1 commented Apr 29, 2026

Problem

The Android implementation of Carrot.setup() could call MethodChannel.Result multiple times in certain error scenarios (e.g. HTTP 400 or RxJava composite errors).

This leads to a Flutter runtime crash:
java.lang.IllegalStateException: Reply already submitted

What fixed

Introduced a thread-safe guard using AtomicBoolean to ensure that the result is returned only once per method call.

val replied = AtomicBoolean(false)

if (replied.compareAndSet(false, true)) {
    result.success(...)
}

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