server(session): Handle failed writes to the connection gracefully.