Skip to content

Commit

Permalink
fix: use rejected Promise for terminate() (#845)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian committed Jan 8, 2020
1 parent 006ebcb commit f2c4d91
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dev/src/pool.ts
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
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

0 comments on commit f2c4d91

Please sign in to comment.