Skip to content

NIOCore/NIOLoopBound.swift:120: Precondition failed in 2.14.0  #140

@jhoughjr

Description

@jhoughjr

Describe the bug

I'm seeing a precondition failed when setting onText or onBinary on an upgraded websocket.

To Reproduce

vapor new testing; cd testing; open Package.swift;

add the following route to routes.swift

  app.webSocket("test",
                  maxFrameSize: WebSocketMaxFrameSize.default) { req in
        return req.headers
        
    } onUpgrade: { req, webSoc in
        
        webSoc.onText { ws, text in
            app.logger.info("\(text)")
        }
    }

Build and run. Then connect to ws://localhost:8080/test with a websocket client.
When the onText handler is added, the server will crash with precondition failed.

Expected behavior

A properly added onText or onBinary handler that does not fail the box's precondition and crash.

Environment

MacOS 13.4, m1 Mac mini 2020
Xcode 14.3.1
Vapor: 4.77.0
toolbox: 18.7.1
websocket-kit: 2.14.0

Additional context

Add any other context about the problem here.

[ INFO ] GET /test [request-id: 1E6A83B5-84A4-4234-B5B2-B705F9F8C8BB]
NIOCore/NIOLoopBound.swift:120: Precondition failed
2023-06-14 08:23:57.758835-0500 App[44596:2119282] NIOCore/NIOLoopBound.swift:120: Precondition failed```

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions