Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Sources/NIOCore/EventLoopFuture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

@MaxDesiatov MaxDesiatov Nov 3, 2025

Choose a reason for hiding this comment

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

This should fix CI breakage.

Suggested change
try self._blockingWaitForFutureCompletion(file: file, line: line)
return try self._blockingWaitForFutureCompletion(file: file, line: line)

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Member

@MaxDesiatov MaxDesiatov Nov 3, 2025

Choose a reason for hiding this comment

The 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?

docker run -v /home/runner/work/swift-nio/swift-nio:/swift-nio -w /swift-nio \
  -e CI=true -e GITHUB_ACTIONS=true -e SWIFT_VERSION=6.0 \
  -e workspace=/swift-nio swift:6.0-jammy bash

}

Expand Down
Loading