birdofpreyru / react-native-static-server

Embedded HTTP server for React Native
https://dr.pogodin.studio/docs/react-native-static-server
Other
142 stars 22 forks source link

[Android] Bug: If a server crashes once, all subsequence attempts to start a server will fail, unless the host app is restarted #30

Closed birdofpreyru closed 1 year ago

birdofpreyru commented 1 year ago

This happens because here we safeguard against multiple server instances launched in the app, but the only place we reset server variable, here, is reacheable only when no errors happen. If server exits with an error, it is not reset to null. To fix, need correctly reset it to null in case of failures inside the server signals handler.

https://github.com/birdofpreyru/react-native-static-server/blob/a95b656bfd89b9ba8f83dec85429b2a147a8d52c/android/src/main/java/com/drpogodin/reactnativestaticserver/ReactNativeStaticServerModule.java#L107-L117