Skip to content
Merged
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,7 +1091,27 @@ 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."
)
#else
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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MaxDesiatov I didn't see that command during my cursory glance through the build logs because it was folded inline. I opted to just build this on my own fork instead to get as close as possible to the CI in this fork.

Here is the passing build testing my latest push to verify proper a proper build failure fix: https://github.com/PassiveLogic/swift-nio/actions/runs/19044020204/job/54387663452?pr=1

But to answer your question, that command does run on my machine, but it doesn't seem to kick off any swift builds.

I found the following similar command in the build log, but it fails for me at the apt-get step.

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 -c swift --version && apt-get update -y -q && apt-get install -y -q curl jq && curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-cxx-interop-compatibility.sh | bash 

#endif
}

@inlinable
Expand Down