Skip to content

feat: Enable WebAssembly compilation#2

Merged
krodak merged 1 commit into
PassiveLogic:mainfrom
krodak:feat/wasm-compilation
Jul 21, 2026
Merged

feat: Enable WebAssembly compilation#2
krodak merged 1 commit into
PassiveLogic:mainfrom
krodak:feat/wasm-compilation

Conversation

@krodak

@krodak krodak commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Overview

Add WebAssembly (wasm32-unknown-wasip1) support to AsyncKit. On wasi it builds on upstream apple/swift-nio (NIOCore) plus the standalone PassiveLogic/nio-async-runtime for the event loop, gating out NIOPosix. Non-wasm platforms compile the same NIOPosix code as before, so swift-nio stays vanilla for consumers.

The one runtime adaptation is connection-pool shutdown: where Dispatch is unavailable (wasm), the DispatchQueue / DispatchGroup path falls back to structured concurrency (Task / withTaskGroup), and the blocking syncShutdownGracefully() is compiled out.

Links

What changed

  • Package.swift - depend on upstream apple/swift-nio (from 2.89.0) + PassiveLogic/nio-async-runtime; gate NIOPosix to non-wasi and NIOAsyncRuntime to wasi on the AsyncKit and test targets.
  • Sources/AsyncKit/ConnectionPool/EventLoopGroupConnectionPool.swift - #if canImport(Dispatch) guards; a Task / withTaskGroup shutdown fallback for wasm; syncShutdownGracefully() compiled out where Dispatch is absent.
  • Sources/AsyncKit/ConnectionPool/EventLoopConnectionPool.swift - explicit DequeModule / OrderedCollections imports (required by the MemberImportVisibility upcoming feature).
  • Sources/AsyncKit/Exports.swift - re-export MultiThreadedEventLoopGroup from NIOAsyncRuntime on wasi and NIOPosix elsewhere; gate NIOEmbedded off wasi.
  • Tests/AsyncKitTests/ConnectionPoolTests.swift - explicit NIOPosix.MultiThreadedEventLoopGroup import (previously came via the re-export).
  • .github/workflows/test.yml - enable the wasm job (with_wasm: true).

Tested

  • swift build
  • swift build --swift-sdk swift-6.3-RELEASE_wasm

Add wasm (wasm32-unknown-wasip1) support: depend on upstream apple/swift-nio
plus the standalone PassiveLogic/nio-async-runtime for the wasi event loop, and
gate NIOPosix to non-wasi. NIOCore stays shared. Dispatch-based connection-pool
shutdown falls back to structured concurrency (Task / withTaskGroup) where
Dispatch is unavailable, and the blocking syncShutdownGracefully() is compiled
out on wasi. Non-wasm builds compile the same NIOPosix code as before.

Co-authored-by: Scott Marchant <scottm@passivelogic.com>
@krodak
krodak force-pushed the feat/wasm-compilation branch from fc5cfd4 to db3a187 Compare July 21, 2026 16:55
@krodak
krodak merged commit 967a624 into PassiveLogic:main Jul 21, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants