Fix flaky IAP flow test: spurious async and mock delays#32
Draft
Copilot wants to merge 2 commits into
Draft
Conversation
Agent-Logs-Url: https://github.com/damus-io/api/sessions/9ac7edf6-1445-487b-8ab5-4e8a3fac7d03 Co-authored-by: danieldaquino <24692108+danieldaquino@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix flaky IAP flow test for consistent results
Fix flaky IAP flow test: spurious async and mock delays
May 4, 2026
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.
The IAP flow test suite was non-deterministic due to two compounding bugs that caused it to exceed tap's 30-second per-file timeout on slower CI machines.
Root causes
1.
should_iap_transaction_history_be_refreshedincorrectly declaredasyncThe function had no
awaitinside it but was declaredasync, and its call site omittedawait. This meant the guard check received aPromise(always truthy) instead of a boolean — so!should_iap_transaction_history_be_refreshed(account)was alwaysfalseand the early-return never fired. EveryGET /accounts/:pubkeycall triggered a full Apple IAP refresh, even for active accounts that needed no refresh.2. Artificial 500ms delays in the mock IAP controller
getTransactionHistoryandverifyAndDecodeTransactioneach usedsetTimeout(…, 500). Combined with the always-refresh bug, everyGETcall added 500ms (fetch) + 500ms × N (decode), pushing the test file from ~3s to ~17s — near the timeout limit. Thereject()calls also lacked areturn, falling through to a subsequentresolve().Impact