Skip to content

Conversation

gbirch-stripe
Copy link
Contributor

@gbirch-stripe gbirch-stripe commented Sep 9, 2025

Summary

  • Promises are not thread safe and can cause crashes and should be eliminated from the SDK. Marking them as deprecated to discourage people from adding new code with them
  • AsyncTests are regularly failing not because of issues with the tests but because the Promises code they are testing is buggy. Removing these tests since they do not provide us with any information and slow down CI

Motivation

Ensure that no new promise code is added to the SDK
Remove CI friction

Testing

N/A

Changelog

N/A

@gbirch-stripe gbirch-stripe changed the title Deprecate Promises Deprecate Promises, remove AsyncTests Sep 9, 2025
Copy link

github-actions bot commented Sep 9, 2025

⚠️ Public API changes detected:

StripePayments

- public var allResponseFields: [Swift.AnyHashable : Any] {
- get
- }
- public var allResponseFields: [Swift.AnyHashable : Any] {
- get
- }
- public var allResponseFields: [Swift.AnyHashable : Any] {
- get
- }

If you are adding a new public API consider the following:

  • Do these APIs need to be public or can they be protected with @_spi(STP)?
  • If these APIs need to be public, assess whether they require an API review.

If you are modifying or removing a public API:

  • Does this require a breaking version change?
  • Do these changes require API review?

If you confirm these APIs need to be added/updated and have undergone necessary review, add the label modifies public API to this PR to acknowledge and bypass this check.

ℹ️ If this comment appears to be left in error, make sure your branch is up-to-date with master.

@gbirch-stripe gbirch-stripe marked this pull request as ready for review September 9, 2025 22:12
@gbirch-stripe gbirch-stripe requested review from a team as code owners September 9, 2025 22:12
@gbirch-stripe gbirch-stripe requested review from a team, joyceqin-stripe, davidme-stripe, wooj-stripe and porter-stripe and removed request for a team September 9, 2025 22:13
}

func testFutureChainedFailure() {
let promise = Promise<Int>()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are promises still being used in the code base anywhere? Even though we don't want people to use them in the future and the tests are flakey I'm a little fud-ful of removing the tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They're used in financial connections and identity, and I've notified both teams of this. The issue with keeping the tests around is that some of the scenarios they test are indeed broken, and the only reason they usually pass is that we're not getting unlucky with the timing. So between failing all the time and only passing because they're not accurate, I'm not sure what the purpose of them is

Copy link
Collaborator

Choose a reason for hiding this comment

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

cc @mats-stripe can you review and see if this looks good as only FC and Identity use promises?

@@ -123,6 +124,7 @@ import Foundation
}
}

// ⛔️ DEPRECATED: Promises are not fully thread safe and can cause crashes. Use Swift concurrency instead. ⛔️
@_spi(STP) public class Promise<Value>: Future<Value> {
Copy link
Collaborator

@porter-stripe porter-stripe Sep 16, 2025

Choose a reason for hiding this comment

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

The comments may get overlooked or not seen, one idea is to move this from STP to something like "DeprecatedPromises" or something so future users need to ack that they are deprecated if they start using them in a place where they aren't currently used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tinkered with this but decided against it since the only reason I can imagine someone writing new Promise code is to interact with existing Promise code, which there's no way around right now due to lack of interoperability. So my feeling was that it was add friction without benefit, but I think I still have the commit somewhere so I'm curious to hear your thoughts

@gbirch-stripe
Copy link
Contributor Author

Tracking removal of Promise code:
Identity: #5557
FC: https://jira.corp.stripe.com/browse/RUN_LINK_MOBILE-34

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.

2 participants