Commit f76f15e
authored
feat!: Timeout executor to fix race conditions on timeout (#457)
**Requirements**
- [x ] I have added test coverage for new or changed functionality
- [ x] I have followed the repository's [pull request submission
guidelines](../blob/v9/CONTRIBUTING.md#submitting-pull-requests)
- [ x] I have validated my changes against all supported platform
versions
**Describe the solution you've provided**
Implemented Timeout executor to fix race condition, when completions
could called twice, by providing stable implementation of Timeout
**Describe alternatives you've considered**
Provide a clear and concise description of any alternative solutions or
features you've considered.
**Additional context**
Add any other context about the pull request here.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Introduces a reusable TimeoutExecutor and uses it to streamline
timeout behavior in LDClient identify and start, with accompanying unit
tests and project wiring.
>
> - **Core**:
> - **Utility**: Add `ServiceObjects/TimeoutExecutor.swift` to run async
operations with a timeout fallback and ensure single completion.
> - **Refactor**: Replace custom timeout logic in
`LDClient.identify(context:timeout:useCache:completion:)` and
`LDClient.start(..., startWaitSeconds:, ...)` with `TimeoutExecutor`.
> - **Tests**:
> - Add `LaunchDarklyTests/ServiceObjects/TimeoutExecutorSpec.swift`
covering result-before-timeout, timeout fallback, race conditions, queue
execution, nil completion, and late-result ignored.
> - **Project**:
> - Wire new sources/tests into all targets; set team id for tests.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
6630979. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->File tree
4 files changed
+282
-31
lines changed- LaunchDarkly.xcodeproj
- LaunchDarkly
- LaunchDarklyTests/ServiceObjects
- LaunchDarkly
- ServiceObjects
4 files changed
+282
-31
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
41 | 46 | | |
42 | 47 | | |
43 | 48 | | |
| |||
429 | 434 | | |
430 | 435 | | |
431 | 436 | | |
| 437 | + | |
| 438 | + | |
432 | 439 | | |
433 | 440 | | |
434 | 441 | | |
| |||
629 | 636 | | |
630 | 637 | | |
631 | 638 | | |
| 639 | + | |
632 | 640 | | |
633 | 641 | | |
634 | 642 | | |
| |||
887 | 895 | | |
888 | 896 | | |
889 | 897 | | |
| 898 | + | |
890 | 899 | | |
891 | 900 | | |
892 | 901 | | |
| |||
1355 | 1364 | | |
1356 | 1365 | | |
1357 | 1366 | | |
| 1367 | + | |
1358 | 1368 | | |
1359 | 1369 | | |
1360 | 1370 | | |
| |||
1481 | 1491 | | |
1482 | 1492 | | |
1483 | 1493 | | |
| 1494 | + | |
1484 | 1495 | | |
1485 | 1496 | | |
1486 | 1497 | | |
| |||
1508 | 1519 | | |
1509 | 1520 | | |
1510 | 1521 | | |
| 1522 | + | |
1511 | 1523 | | |
1512 | 1524 | | |
1513 | 1525 | | |
| |||
1606 | 1618 | | |
1607 | 1619 | | |
1608 | 1620 | | |
| 1621 | + | |
1609 | 1622 | | |
1610 | 1623 | | |
1611 | 1624 | | |
| |||
1639 | 1652 | | |
1640 | 1653 | | |
1641 | 1654 | | |
| 1655 | + | |
1642 | 1656 | | |
1643 | 1657 | | |
1644 | 1658 | | |
| |||
2019 | 2033 | | |
2020 | 2034 | | |
2021 | 2035 | | |
| 2036 | + | |
2022 | 2037 | | |
2023 | 2038 | | |
2024 | 2039 | | |
| |||
2030 | 2045 | | |
2031 | 2046 | | |
2032 | 2047 | | |
| 2048 | + | |
2033 | 2049 | | |
2034 | 2050 | | |
2035 | 2051 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
403 | 399 | | |
404 | 400 | | |
405 | 401 | | |
| |||
854 | 850 | | |
855 | 851 | | |
856 | 852 | | |
857 | | - | |
858 | 853 | | |
859 | 854 | | |
860 | 855 | | |
| 856 | + | |
861 | 857 | | |
862 | 858 | | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | | - | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
869 | 865 | | |
870 | | - | |
871 | | - | |
872 | | - | |
873 | | - | |
874 | | - | |
875 | | - | |
876 | | - | |
877 | | - | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
878 | 870 | | |
879 | 871 | | |
880 | 872 | | |
| |||
Lines changed: 76 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
0 commit comments