-
Notifications
You must be signed in to change notification settings - Fork 0
chore/replace swift concurrency #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
mui-z
commented
Aug 31, 2025
- refactor(concurrency): adopt async/await for simctl execution with concurrent stdout/stderr draining and timeout race
- fix(concurrency): resolve Swift 6 compile errors by removing async-let capture in race and marking SimulatorService Sendable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codex Review: Here are some suggestions.
Reply with @codex fix comments
to fix any unresolved comments.
About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".
…ncurrent stdout/stderr draining and timeout race
…t capture in race and marking SimulatorService Sendable
e7a34b0
to
21fc5c2
Compare
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codex Review: Here are some suggestions.
Reply with @codex fix comments
to fix any unresolved comments.
About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".
// Race process exit vs timeout sleep | ||
let first = await withTaskGroup(of: Int.self) { group -> Int in | ||
group.addTask { await waitForExitAsync(process); return 0 } | ||
group.addTask { try? await Task.sleep(nanoseconds: timeoutNanos); return 1 } | ||
return await group.next() ?? 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Reinstate non-blocking timeout race for simctl process
The new timeout logic uses withTaskGroup
to race waitForExitAsync
against Task.sleep
, but the call returns only after all child tasks complete. Because waitForExitAsync
never observes cancellation, the group will wait for the simulator process to exit even when the sleep finishes first, so the timeout path cannot fire until the command ends naturally. As a result, hung simctl
invocations still block indefinitely and the termination/kill logic is never reached in time.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@codex fix comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
- Made
waitForExitAsync
cancellation-aware by combining a task cancellation handler withProcess.terminationHandler
, allowing the continuation to resume when either the process completes or the task is cancelledSources/XSimCLI/Services/SimulatorService.swiftL81-L92 - Cancelled any remaining task‑group operations after the first one finishes, preventing the timeout race from waiting on the slower taskSources/XSimCLI/Services/SimulatorService.swiftL98-L105
Testing
- ❌
make format
(swiftformat: No such file or directory) ⚠️ swift build
(Failed to clone repository https://github.com/jakeheis/SwiftCLI/)⚠️ swift test
(Failed to clone repository https://github.com/jakeheis/SwiftCLI/)