Skip to content

Deal with Sendable and clean up package in general #158

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

Merged
merged 5 commits into from
Apr 27, 2025
Merged

Conversation

gwynne
Copy link
Member

@gwynne gwynne commented Apr 26, 2025

These changes are now available in 2.16.0

Covers fixing a bunch of Sendable things and does the usual round of package cleanup - bump the Swift minimum to 5.10, update the CI and the README, and so forth. Also fixes up some issues in the tests.

@gwynne gwynne added the semver-minor Contains new APIs label Apr 26, 2025
@gwynne gwynne requested review from 0xTim, MahdiBM and ptoffy April 26, 2025 06:38
Copy link

codecov bot commented Apr 26, 2025

Codecov Report

Attention: Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 82.39%. Comparing base (a935b63) to head (3b0e716).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...urces/WebSocketKit/HTTPUpgradeRequestHandler.swift 0.00% 1 Missing ⚠️
Sources/WebSocketKit/WebSocketHandler.swift 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #158      +/-   ##
==========================================
- Coverage   82.85%   82.39%   -0.46%     
==========================================
  Files           6        6              
  Lines         659      659              
==========================================
- Hits          546      543       -3     
- Misses        113      116       +3     
Files with missing lines Coverage Δ
...bSocketKit/Concurrency/WebSocket+Concurrency.swift 48.80% <ø> (ø)
Sources/WebSocketKit/WebSocket+Connect.swift 98.59% <ø> (ø)
Sources/WebSocketKit/WebSocket.swift 88.12% <100.00%> (-0.92%) ⬇️
Sources/WebSocketKit/WebSocketClient.swift 94.70% <100.00%> (-0.65%) ⬇️
...urces/WebSocketKit/HTTPUpgradeRequestHandler.swift 71.92% <0.00%> (ø)
Sources/WebSocketKit/WebSocketHandler.swift 63.79% <90.90%> (+1.29%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gwynne
Copy link
Member Author

gwynne commented Apr 26, 2025

5.10 CI failure is caused by NIO, see apple/swift-nio#3223

@@ -547,12 +547,12 @@ final class WebSocketKitTests: XCTestCase {
}

func testCreateNewELGAndShutdown() throws {
let client = WebSocketClient(eventLoopGroupProvider: .createNew)
let client = WebSocketClient(eventLoopGroupProvider: .shared(.singletonMultiThreadedEventLoopGroup))
Copy link
Contributor

Choose a reason for hiding this comment

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

Did this have a warning or something? because the test name doesn't quite match the change you made.

Copy link
Member Author

Choose a reason for hiding this comment

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

.createNew is deprecated and I wasn't paying attention to the test name 🤦‍♀️

Copy link
Member

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

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

One query around sendability

import NIOCore
import NIOHTTP1

final class HTTPUpgradeRequestHandler: ChannelInboundHandler, RemovableChannelHandler {
final class HTTPUpgradeRequestHandler: ChannelInboundHandler, RemovableChannelHandler, Sendable {
Copy link
Member

Choose a reason for hiding this comment

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

Why does this need to be Sendable?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because I didn't think of using NIOLoopBound first. I'll change it.

let responseEncoder = HTTPResponseEncoder()
let requestDecoder = ByteToMessageHandler(HTTPRequestDecoder(leftOverBytesStrategy: .forwardBytes))
let proxySimulator = HTTPProxySimulator(promise: promise, config: proxyConfig, expectedAuthorization: expectedAuthorization)
let responseEncoder = NIOLoopBound(HTTPResponseEncoder(), eventLoop: channel.eventLoop)
Copy link
Member

Choose a reason for hiding this comment

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

It's tests so doesn't matter as much but why the loop bound dance here? We're @unchecked Sendable and @preconcurrency importing the types. I would have assumed one of the 3 approaches would be enough

Copy link
Member Author

Choose a reason for hiding this comment

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

Because futures are now Strict Concurrency-correct and everything you capture in a closure has to be Sendable in ways that @preconcurrency would only silence if you applied it to the entire NIOCore import.

@gwynne gwynne requested a review from 0xTim April 26, 2025 18:02
Copy link
Member

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

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

Nice to see the tests passing again! That should at least unblock other PRs

@gwynne gwynne merged commit 014ccd5 into main Apr 27, 2025
25 of 26 checks passed
@gwynne gwynne deleted the sendable-and-cleanup branch April 27, 2025 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor Contains new APIs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants