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

RSTUDIO-540: Fix connect to server #1666

Merged
merged 5 commits into from
Jun 20, 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: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# Changelog
## vNext (TBD)

### Enhancements
* None

### Fixed
* Fixed connecting to the server and opening synced Realms ([#1665](https://github.com/realm/realm-studio/issues/1665), since v15.0.0)

### Internals
* None

## 15.2.0 (2024-06-12)

Expand Down
2 changes: 1 addition & 1 deletion src/ui/ConnectToServer/ConnectToServer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const ConnectToServer = ({
type="url"
name="serverUrl"
id="serverUrl"
placeholder="https://realm.mongodb.com"
placeholder="https://services.cloud.mongodb.com"
value={url}
onChange={onUrlChanged}
/>
Expand Down
8 changes: 4 additions & 4 deletions src/ui/ConnectToServer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ import {

import { ConnectToServer } from './ConnectToServer';

const DEFAULT_BASE_URL = 'https://realm.mongodb.com';
const DEFAULT_BASE_URL = 'https://services.cloud.mongodb.com';
const LEGACY_BASE_URL = 'https://realm.mongodb.com';
Comment on lines +38 to +39
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and updated the base URL in the PR as well.


/*
const MISSING_PARAMS_MESSAGE =
Expand Down Expand Up @@ -83,7 +84,7 @@ class ConnectToServerContainer extends React.Component<
const url = this.props.url || this.getLatestUrl();
this.setState({
// Use an empty input instead of filling in the default URL
url: url === DEFAULT_BASE_URL ? '' : url,
url: url === DEFAULT_BASE_URL || url === LEGACY_BASE_URL ? '' : url,
appId: this.getLatestAppId(),
});
// this.restoreCredentials(url);
Expand Down Expand Up @@ -114,9 +115,8 @@ class ConnectToServerContainer extends React.Component<
const { appId, url } = this.state;
// Use SDK default (passing undefined) on an empty string.
const baseUrl = url || DEFAULT_BASE_URL;
// Clear test state to invalidate the shared App cache as a work around for
// TODO: Clear test state to invalidate the shared App cache as a work around for
Copy link
Member Author

@kraenhansen kraenhansen Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my testing, I'm unable to reproduce this and it seems fair to disable the workaround for now. I'm leaving the comment for a future where this resurfaces.

// https://github.com/realm/realm-js/issues/6276
(Realm.App as any)._clearAppCache();
const app = new App({ id: appId, baseUrl });
const serializedCredentials = this.serializeCredentials();
const credentials = hydrateCredentials(serializedCredentials);
Expand Down
4 changes: 3 additions & 1 deletion src/ui/reusable/RealmLoadingComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,12 @@ export abstract class RealmLoadingComponent<
});
const credentials = hydrateCredentials(realm.credentials);
const user = await app.logIn(credentials);
return new Realm({
return Realm.open({
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Realm.open here to ensure the schema gets downloaded before the Realm is considered loaded.

encryptionKey: realm.encryptionKey,
sync: {
user,
flexible: true,
/*
initialSubscriptions: {
update(subs, realm) {
for (const schema of realm.schema) {
Expand All @@ -169,6 +170,7 @@ export abstract class RealmLoadingComponent<
}
},
},
*/
Copy link
Member Author

@kraenhansen kraenhansen Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabling the initial subscription, since this could potentially result in a huge download that we don't want to wait for.

},
schema,
schemaVersion,
Expand Down
Loading