             connectPromise.fail(error: error)
         }
 
-        callouts(self.pipeline)
+        callouts(p, self.pipeline)
 
         eventLoop.execute {
             // ensure this is executed in a delayed fashion as the users code may still traverse the pipeline

    }

    @inline(__always) // we need to return a closure here and to not suffer from a potential allocation for that this must be inlined
    internal mutating func beginRegistration(promise: EventLoopPromise<Void>?) -> ((ChannelPipeline) -> Void) {
        return self.moveState(event: .beginRegistration, promise: promise)
    }

    @inline(__always) // we need to return a closure here and to not suffer from a potential allocation for that this must be inlined
    internal mutating func finishRegistration(promise: EventLoopPromise<Void>?) -> ((ChannelPipeline) -> Void) {
        return self.moveState(event: .finishRegistration, promise: promise)
    }

    @inline(__always) // we need to return a closure here and to not suffer from a potential allocation for that this must be inlined
    internal mutating func close(promise: EventLoopPromise<Void>?) -> ((ChannelPipeline) -> Void) {
        return self.moveState(event: .close, promise: promise)
    }

    @inline(__always) // we need to return a closure here and to not suffer from a potential allocation for that this must be inlined
    internal mutating func activate(promise: EventLoopPromise<Void>?) -> ((ChannelPipeline) -> Void) {
        return self.moveState(event: .activate, promise: promise)
    }

    // MARK: private API
    @inline(__always) // we need to return a closure here and to not suffer from a potential allocation for that this must be inlined
    private mutating func moveState(event: Event, promise: EventLoopPromise<Void>?) -> ((ChannelPipeline) -> Void) {
        self.eventLoop.assertInEventLoop()

        switch (self.currentState, event) {
        // origin: .fresh
        case (.fresh, .beginRegistration):
            return self.doStateTransfer(newState: .preRegistered, promise: promise) { pipeline in
                pipeline.fireChannelRegistered0()
            }

        case (.fresh, .close):
            return self.doStateTransfer(newState: .closed, promise: promise) { (_: ChannelPipeline) in }

        // origin: .preRegistered
        case (.preRegistered, .finishRegistration):
            return self.doStateTransfer(newState: .fullyRegistered, promise: promise) { pipeline in
                // we don't tell the user about this
            }

        // origin: .fullyRegistered
        case (.fullyRegistered, .activate):
            return self.doStateTransfer(newState: .activated, promise: promise) { pipeline in
                pipeline.fireChannelActive0()
            }

        // origin: .preRegistered || .fullyRegistered
        case (.preRegistered, .close), (.fullyRegistered, .close):
            return self.doStateTransfer(newState: .closed, promise: promise) { pipeline in
                pipeline.fireChannelUnregistered0()
            }

        // origin: .activated
        case (.activated, .close):
            return self.doStateTransfer(newState: .closed, promise: promise) { pipeline in
                pipeline.fireChannelInactive0()
                pipeline.fireChannelUnregistered0()
            }


        // We always register with interested .none and will just trigger readIfNeeded0() later to re-register if needed.
        try self.safeRegister(interested: [.readEOF, .reset])
        self.lifecycleManager.finishRegistration()(nil, self.pipeline)
    }

    final func becomeActive0(promise: EventLoopPromise<Void>?) {
