Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Randomize the downloaded bundle filename #16312

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public class DevSupportManagerImpl implements

private static final int JAVA_ERROR_COOKIE = -1;
private static final int JSEXCEPTION_ERROR_COOKIE = -1;
private static final String JS_BUNDLE_FILE_NAME = "ReactNativeDevBundle.js";
private static final String JS_BUNDLE_FILE_FORMAT = "ReactNativeDevBundle.%d.js";
private static enum ErrorType {
JS,
NATIVE
Expand Down Expand Up @@ -229,11 +229,15 @@ public void onReceive(Context context, Intent intent) {
};

// We store JS bundle loaded from dev server in a single destination in app's data dir.
// (We randomize the name in the event that there are multiple JS bridges running.)
// In case when someone schedule 2 subsequent reloads it may happen that JS thread will
// start reading first reload output while the second reload starts writing to the same
// file. As this should only be the case in dev mode we leave it as it is.
// TODO(6418010): Fix readers-writers problem in debug reload from HTTP server
mJSBundleTempFile = new File(applicationContext.getFilesDir(), JS_BUNDLE_FILE_NAME);
mJSBundleTempFile = new File(
applicationContext.getFilesDir(),
String.format(JS_BUNDLE_FILE_FORMAT, (int)(Math.random() * 1000000))
);

mDefaultNativeModuleCallExceptionHandler = new DefaultNativeModuleCallExceptionHandler();

Expand Down