Skip to content

[in_app_purchase_storekit] Complete StoreKit 2 finish when the transaction is not found - #13037

Merged
auto-submit[bot] merged 1 commit into
flutter:mainfrom
anilcancakir:fix-192400
Oct 8, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:mainfrom
anilcancakir:fix-192400

Conversation

@anilcancakir

@anilcancakir anilcancakir commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

StoreKit 2 finish(id:completion:) only called completion when fetchTransaction found the transaction. fetchTransaction searches Transaction.all, which by default does not contain finished consumables, so a second completePurchase for a consumable that was already finished (for example after a duplicate delivery) returned a Future that never completed. The StoreKit 1 path already treats a missing transaction as success (testFinishTransactionSucceedsWithNilTransaction).

This PR:

  • Calls completion(.success(Void())) after the lookup whether or not a transaction was found.
  • Removes the throws from fetchTransaction, which has no throwing call. This rules out the second hang the issue describes (an error thrown inside the Task in finish and never reported) and clears the Xcode 27 warning unstructured throwing task ... may accidentally ignore errors thrown inside the task. The one test caller drops its now unneeded try.
  • Adds testFinishTransactionSucceedsWhenAlreadyFinished, which purchases a consumable and finishes it twice; the second finish times out without the fix and passes with it.
  • Makes testFinishTransaction also check that the purchase is no longer unfinished, since its completion alone no longer proves the transaction was found.

Tested with the iOS RunnerTests on an iOS 26.2 simulator, the CI destination.

This only makes the Future complete; it does not change which transactions StoreKit redelivers.

Fixes flutter/flutter#192400

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2

…ction is missing

finish(id:) only called its completion when fetchTransaction found the
transaction. Transaction.all excludes finished consumables by default, so
a second completePurchase() for an already finished consumable never
completed.

Always call the completion after the lookup, and drop the unused throws
from fetchTransaction so no error can be silently lost inside the Task.

Fixes flutter/flutter#192400
@google-cla

google-cla Bot commented Sep 27, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@anilcancakir
anilcancakir marked this pull request as ready for review September 27, 2026 21:40

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request modifies the StoreKit 2 implementation to ensure finish(id:completion:) completes successfully when a transaction is not found, matching StoreKit 1 behavior. It also removes the throws specifier from fetchTransaction(by:) and adds unit tests to verify finishing already completed transactions. Feedback recommends using UInt64(bitPattern:) instead of UInt64(id) to avoid potential runtime crashes from negative signed integers.

@LouiseHsu LouiseHsu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm!

@LouiseHsu

Copy link
Copy Markdown
Contributor

cc @LongCatIsLooong :)

@LongCatIsLooong LongCatIsLooong added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 8, 2026
@auto-submit
auto-submit Bot merged commit d0bf954 into flutter:main Oct 8, 2026
12 checks passed
jmagman pushed a commit to jmagman/flutter that referenced this pull request Oct 9, 2026
flutter/packages@54706bd...d8d9e97

2026-10-09 [email protected] [pigeon] Reject unsupported native
interop features and fix generated code that doesn't compile
(flutter/packages#13153)
2026-10-09 [email protected] [material_ui] Fix
ExpansionTile WidgetSpan semantics assertion (flutter/packages#12765)
2026-10-08 [email protected] [in_app_purchase_storekit] Complete
StoreKit 2 `finish` when the transaction is not found
(flutter/packages#13037)
2026-10-08 [email protected] [video_player] Fix crash when
videoTrack has zero-duration minFrameDuration (flutter/packages#12796)
2026-10-08 [email protected]
[google_maps_flutter_platform_interface] Add map background color
configuration (flutter/packages#13014)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
flutter/packages@54706bd...d8d9e97

2026-10-09 [email protected] [pigeon] Reject unsupported native
interop features and fix generated code that doesn't compile
(flutter/packages#13153)
2026-10-09 [email protected] [material_ui] Fix
ExpansionTile WidgetSpan semantics assertion (flutter/packages#12765)
2026-10-08 [email protected] [in_app_purchase_storekit] Complete
StoreKit 2 `finish` when the transaction is not found
(flutter/packages#13037)
2026-10-08 [email protected] [video_player] Fix crash when
videoTrack has zero-duration minFrameDuration (flutter/packages#12796)
2026-10-08 [email protected]
[google_maps_flutter_platform_interface] Add map background color
configuration (flutter/packages#13014)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD p: in_app_purchase platform-ios platform-macos triage-ios Should be looked at in iOS triage

Projects

None yet

4 participants