Skip to content

Commit

Permalink
Fix db.useEmulator
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian committed Apr 23, 2021
1 parent d442eb2 commit 9f0b203
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
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

0 comments on commit 9f0b203

Please sign in to comment.