fix: support network throttle bypass origins - #82
Conversation
| private class ThrottleInterceptor : Interceptor { | ||
| override fun intercept(chain: Interceptor.Chain): Response { | ||
| val request = chain.request() | ||
| if (shouldBypass(request.url)) { |
There was a problem hiding this comment.
P2: [Android bypass policy does not follow redirects]
When this URL redirects across origins, this check evaluates only the initial request. ThrottleInterceptor is installed as an OkHttp application interceptor, so chain.proceed() follows redirects without invoking this bypass check again.
As a result, a request starting on a bypassed origin can redirect to a non-bypassed origin and still skip all throttling; the reverse direction can keep throttling a bypassed target. Please evaluate the bypass set for each network exchange or redirect target, and cover redirects both into and out of bypassed origins.
Automated code review found blocking issuesReviewed commit Review summaryThe PR extends the React Native network-throttle configuration path with additive, process-lifetime HTTP(S) origin bypasses. JavaScript normalizes configuration returned by older native binaries, while iOS and Android canonicalize origins, store them in native shared state, expose them through the existing bridge, and consult them before applying latency or bandwidth throttling. What needs attention: Correct Android redirect handling so every effective request origin receives the intended bypass decision, then cover cross-origin redirects with native behavior tests. Issues to address
Validation gaps
|
Summary
bypassUrlOriginsconfiguration to@onekeyfe/react-native-network-throttle.3.0.82-alpha.0through thenextnpm dist-tag for OneKeyHQ/app-monorepo#12831.Intent & Context
The host app's weak-network development setting should affect remote network requests without delaying Metro bundles and development assets. The native interception behavior belongs in this package rather than a patch-package override in the app repository.
Root Cause
The native interceptors treated every React Native HTTP(S) request as throttleable. When Metro served the JavaScript bundle or assets over HTTP, those local development resources received the same latency and bandwidth limits as remote API traffic.
Design Decisions
mainandbgJavaScript runtimes initialize independently but use the same underlying native throttle state, so one runtime must not clear origins registered by the other.Changes Detail
Risk Assessment
Test plan