-
Notifications
You must be signed in to change notification settings - Fork 712
chore: For WASI builds only, use fatalError in all .wait() calls. Recommend using .get() instead. #3421
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?
chore: For WASI builds only, use fatalError in all .wait() calls. Recommend using .get() instead. #3421
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1091,6 +1091,26 @@ extension EventLoopFuture { | |||||
| @preconcurrency | ||||||
| @inlinable | ||||||
| public func wait(file: StaticString = #file, line: UInt = #line) throws -> Value where Value: Sendable { | ||||||
| #if os(WASI) | ||||||
| // NOTE: As of July 22, 2025 `wait()` calling wait() is not supported on WASI platforms. | ||||||
| // | ||||||
| // This may change down the road if and when true multi-threading evolves. But right now | ||||||
| // calling wait here results in the following runtime crash: | ||||||
| // | ||||||
| // ``` | ||||||
| // SomeExecutable.wasm:0x123456 Uncaught (in promise) RuntimeError: Atomics.wait cannot be called in this context | ||||||
| // ``` | ||||||
| // | ||||||
| // Using the following fatal error here gives wasm runtime users a much more clear error message | ||||||
| // to identify the issue. | ||||||
| // | ||||||
| // If you're running into this error on WASI, refactoring to `get()` instead of `wait()` will | ||||||
| // likely solve the issue. | ||||||
| fatalError( | ||||||
| "NIO's wait() function should not be called on WASI platforms. It will freeze or crash. Use get() instead." | ||||||
| ) | ||||||
| #endif // os(WASI) | ||||||
|
|
||||||
| try self._blockingWaitForFutureCompletion(file: file, line: line) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should fix CI breakage.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, odd that those errors don't show up for me. But could be a linux vs macOS, or swift version difference thing. https://github.com/apple/swift-nio/actions/runs/18985478598/job/54366370185?pr=3421 But I am seeing some compiler warnings in the wasm build. I don't think adding the return will address that warning. I'll push a slightly different revision that should resolve the warnings as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are the errors not reproducible with the exact same invocation and container image that CI uses? |
||||||
| } | ||||||
|
|
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.