Hopefully fix an error case

I have no idea why it's possible for sock.handshake to be defined and then undefined