Closed nicojs closed 6 months ago
I could try setting a timeout or adding a timeout option, but from my testing without internet it looks node seems to immediately return saying it can't connect
require('https')
.get('https://registry.npmjs.org', res => console.log('hello'))
.on('error', err => console.log('error'))
> error
I'm guessing if you're connected to a network that doesn't provide internet access it may attempt to connect and the 10s timeout may be coming from your network? Let me know if you have any thoughts?
I've experimented with this a bit. It seems impossible to handle this correctly, as there is no easy way to 'know' whether you are online or not. When you then await
the result, it might take 10 seconds to time out.
In the examples in the readme, the await
wasn't present. I thought it was a mistake not to await promises, but it is probably a desired effect in this case.
Running simple-update-notifier when offline takes (longer than) 10s when awaited. See this example:
Could we introduce some kind of network check so we don't try the notification when offline?