vapor/vapor

passing non-sendable parameter 'onUpgrade'

GP89 opened this issue · 4 comments

GP89 commented

Describe the bug

I'm getting a compile error on the same commit that was building ok just recently.

It's in a connect method in WebSocket+Concurrency.swift that I don't think I'm using, not directly anyway. I'm build a socket server and I think those extensions are for socket clients

[965/966] Compiling Vapor Application.swift
#0 323.2 /build/.build/checkouts/vapor/Sources/Vapor/Concurrency/WebSocket+Concurrency.swift:135:24: error: passing non-sendable parameter 'onUpgrade' to function expecting a @Sendable closure
#0 323.2             onUpgrade: onUpgrade
#0 323.2                        ^
#0 323.2 /build/.build/checkouts/vapor/Sources/Vapor/Concurrency/WebSocket+Concurrency.swift:124:9: note: parameter 'onUpgrade' is implicitly non-sendable
#0 323.2         onUpgrade: @escaping (WebSocket) -> ()
#0 323.2         ^
#0 323.2                    @Sendable 

To Reproduce

I'm building on linux, and not entirely sure what the issue could be. Possibly something in the library has changed?

I have an exact version of Vapor specified in my Package.swift but possibly that isn't working- I don't know how to check which versions are actually getting used in the build

Expected behavior

A clear and concise description of what you expected to happen.

Environment

  • Vapor Framework version: I have .exact(Version(4, 67, 5)) set in my Package.swift
  • Vapor Toolbox version:
  • OS version: swift:5.6-focal docker container, built on ubuntu

Additional context

Add any other context about the problem here.

This issue is in WebSocketKit, which is the first package that is being attempted to migrate towards Sendable. Though as you have noticed, there are some challenges in trying to support Sendable in Vapor without breaking people's code.

While everyone familiar with Sendable is all for widespread adoption, we've internally noticed this issue and forwarded it to the PR author.

0xTim commented

@GP89 This is technically a Swift bug in 5.6, upgrading to 5.8 will fix it but we're getting a patch done now

GP89 commented

Thanks for the rapid responses guys!!

0xTim commented

@GP89 This should be fixed on all Swift versions now