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

Throwing RealmInExpoGoError only when native module fails to load #6868

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
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
11 changes: 8 additions & 3 deletions packages/realm/src/platform/react-native/binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ declare const global: Record<string, unknown>;
import { NativeModules } from "react-native";
import { NativeBigInt, PolyfilledBigInt, type binding, injectNativeModule } from "../binding";
import { assert } from "../../assert";
import { RealmInExpoGoError, isExpoGo } from "./expo-go-detection";

try {
const RealmNativeModule = NativeModules.Realm;
Expand All @@ -46,7 +47,11 @@ try {
},
});
} catch (err) {
throw new Error(
"Could not find the Realm binary. Please consult our troubleshooting guide: https://www.mongodb.com/docs/realm-sdks/js/latest/#md:troubleshooting-missing-binary",
);
if (isExpoGo()) {
throw new RealmInExpoGoError();
} else {
throw new Error(
"Could not find the Realm binary. Please consult our troubleshooting guide: https://www.mongodb.com/docs/realm-sdks/js/latest/#md:troubleshooting-missing-binary",
);
}
}
4 changes: 0 additions & 4 deletions packages/realm/src/platform/react-native/expo-go-detection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,3 @@ export class RealmInExpoGoError extends Error {
);
}
}

if (isExpoGo()) {
throw new RealmInExpoGoError();
}
Loading