Check port before sending message
On not supported operating systems, we will never create a Port, and thus potentially spam the console with errors.
There's still a few places in e.g. downloads but they call port.postMessage
directly rather than going through sendMessage
...