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: use rejected Promise for terminate() #845

Merged
merged 4 commits into from
Jan 8, 2020
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
2 changes: 1 addition & 1 deletion dev/src/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class ClientPool<T> {
*/
run<V>(requestTag: string, op: (client: T) => Promise<V>): Promise<V> {
if (this.terminated) {
throw new Error('The client has already been terminated');
return Promise.reject('The client has already been terminated');
}
const client = this.acquire(requestTag);

Expand Down
9 changes: 2 additions & 7 deletions dev/system-test/firestore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,14 @@ describe('Firestore class', () => {

it('cannot make calls after the client has been terminated', () => {
const ref1 = randomCol.doc('doc1');
ref1.onSnapshot(snapshot => {
return Promise.reject('onSnapshot() should be called');
});
return firestore
.terminate()
.then(() => {
return ref1.set({foo: 100});
})
.then(() => {
Promise.reject('set() should have failed');
})
.then(() => Promise.reject('set() should have failed'))
.catch(err => {
expect(err.message).to.equal('The client has already been terminated');
expect(err).to.equal('The client has already been terminated');
});
});
});
Expand Down