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

Fix db.useEmulator #4828

Merged
merged 2 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 6 additions & 7 deletions packages/database/src/core/PersistentConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,6 @@ export class PersistentConnection extends ServerActions {
const onReady = this.onReady_.bind(this);
const onDisconnect = this.onRealtimeDisconnect_.bind(this);
const connId = this.id + ':' + PersistentConnection.nextConnectionId_++;
const self = this;
const lastSessionId = this.lastSessionId;
let canceled = false;
let connection: Connection | null = null;
Expand Down Expand Up @@ -807,17 +806,17 @@ export class PersistentConnection extends ServerActions {
.then(result => {
if (!canceled) {
log('getToken() completed. Creating connection.');
self.authToken_ = result && result.accessToken;
this.authToken_ = result && result.accessToken;
connection = new Connection(
connId,
self.repoInfo_,
self.applicationId_,
this.repoInfo_,
this.applicationId_,
onDataMessage,
onReady,
onDisconnect,
/* onKill= */ reason => {
warn(reason + ' (' + self.repoInfo_.toString() + ')');
self.interrupt(SERVER_KILL_INTERRUPT_REASON);
warn(reason + ' (' + this.repoInfo_.toString() + ')');
this.interrupt(SERVER_KILL_INTERRUPT_REASON);
},
lastSessionId
);
Expand All @@ -826,7 +825,7 @@ export class PersistentConnection extends ServerActions {
}
})
.then(null, error => {
self.log_('Failed to get token: ' + error);
this.log_('Failed to get token: ' + error);
if (!canceled) {
if (this.repoInfo_.nodeAdmin) {
// This may be a critical error for the Admin Node.js SDK, so log a warning.
Expand Down
4 changes: 2 additions & 2 deletions packages/database/src/exp/Database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class FirebaseDatabase implements _FirebaseService {

/** @hideconstructor */
constructor(
private _repoInternal: Repo,
public _repoInternal: Repo,
/** The FirebaseApp associated with this Realtime Database instance. */
readonly app: FirebaseApp
) {}
Expand Down Expand Up @@ -300,7 +300,7 @@ export function useDatabaseEmulator(
);
}
// Modify the repo to apply emulator settings
repoManagerApplyEmulatorSettings(db._repo, host, port);
repoManagerApplyEmulatorSettings(db._repoInternal, host, port);
}

/**
Expand Down