Skip to content

Add callback request registry - #1066

Open
vegaro wants to merge 4 commits into
mainfrom
cesar/callback-registry
Open

Add callback request registry#1066
vegaro wants to merge 4 commits into
mainfrom
cesar/callback-registry

Conversation

@vegaro

@vegaro vegaro commented Sep 1, 2026

Copy link
Copy Markdown
Member

Motivation

This is the first part of #1008 which fixes the fact that Purchases stores one mutable callback per operation. Two overlapping calls can overwrite each other, so the first response invokes the wrong callback and the other response is dropped.

Stack

  1. This PR
  2. Pass Unity callback request IDs through Android #1067
  3. Pass Unity callback request IDs through iOS #1068
  4. Fix concurrent Unity callback routing #1008

Note

Low Risk
New internal helper and tests only; no wiring into purchase flows yet.

Overview
Introduces an internal CallbackRegistry so async operations can stash callbacks under unique request IDs instead of sharing a single mutable slot (foundation for fixing overlapping Purchases calls in later stack PRs).

Register<T> returns a GUID string and stores the callback (including null) with its type; TryTake<T> removes and returns the callback only when the ID exists and the type matches—wrong types leave the entry intact. Clear drops all pending entries. Access is guarded with a lock.

Adds EditMode NUnit tests for out-of-order take, single-use IDs, null callbacks, type mismatch, and clear behavior, plus Unity .meta assets.

Reviewed by Cursor Bugbot for commit ee34e88. Bugbot is set up for automated code reviews on this repo. Configure here.

@vegaro vegaro added the pr:other Changes to our CI configuration files and scripts label Sep 1, 2026
@vegaro
vegaro marked this pull request as ready for review September 2, 2026 12:21
@vegaro
vegaro requested a review from a team as a code owner September 2, 2026 12:21
@vegaro
vegaro force-pushed the cesar/callback-registry branch from 9b9e452 to ee34e88 Compare September 2, 2026 12:28

@facumenzella facumenzella left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice work 🙌

heads up, the three red jobs (build-subtester-android, build-subtester-ios, build-integration-tests-ios) all failed on unity/prepare-env,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:other Changes to our CI configuration files and scripts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants