birdofpreyru/react-native-static-server

Unhandled promise rejections in case of failing to auto-stop (-start) the server when the app enters background / foreground

birdofpreyru opened this issue · 0 comments

The content of this handled should be wrapped into try / catch block, with empty catch just ignoring possible rejections if server has any attached state listeners — in that case any error will be forwarded to those listeners by .start() / .stop(), and we assume the consumer handles errors there.

_handleAppStateChange(appState: AppStateStatus) {
if (appState === 'active') this.start('App entered foreground');
else this._stop('App entered background');
}

If no listeners connected, we need to somehow enhance error messages, to make it clear that it is related to the auto server restart.