Skip to content

v1.9.0

@iwater iwater tagged this 07 May 12:30
Major Changes:
1.  **Auto-Restart Feature**: Introduced `autoRestart` in `ServerOptions`. When enabled, the library listens to AppState changes and automatically restarts the server if it's found dead after the app returns to the foreground (common on iOS after background suspension).
2.  **Reliable `isRunning()`**: Refactored `isRunning()` into an asynchronous method. It now performs a real TCP connect probe on the native side with a 200ms timeout to verify the actual socket state, rather than relying on a boolean flag.
3.  **iOS Background Survival**: Added `RNHttpServerBackgroundTask` to request extra background execution time (`beginBackgroundTask`) when the app is backgrounded, extending server uptime during screen lock.
4.  **API Enhancements & Compatibility**:
    *   `start()` methods now accept a `ServerOptions` object while maintaining backward compatibility with the legacy `host` string parameter.
    *   Updated `create*Server` helper functions to support the new configuration options.
5.  **Version Bump**: Updated version to 1.9.0 in `package.json` and changelogs.

Detailed Implementation:
- [TS] Implemented `normalizeOptions` to unify configuration handling.
- [TS] Integrated `AppState` listeners and auto-recovery logic in all Server classes.
- [CPP] Implemented `probe_server_alive` using non-blocking TCP connect.
- [iOS] Added `RNHttpServerBackgroundTask.h/mm` for lifecycle management.
- [DOC] Updated README and README_zh with the new API and features.
Assets 2
Loading