You should have just done:

```javascript
if(!connection.transport) { stuff; return; }
```