Skip to content

Should catch reject promise for closed client #347

@summer-ji-eng

Description

@summer-ji-eng

Unit test for closed client fails on timeout.

it('invokes createTable with closed client', async () => {
      const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({
        credentials: {client_email: 'bogus', private_key: 'bogus'},
        projectId: 'bogus',
      });
      client.initialize();
      const request = generateSampleMessage(
        new protos.google.bigtable.admin.v2.CreateTableRequest()
      );
      const expectedError = new Error('The client has already been closed.');
      client.close();
      await assert.rejects(client.createTable(request), expectedError);
    });

In the client library, if a client has been close, it return reject promise

if (this._terminated) {
              console.log('---terminated');
              return Promise.reject('The client has already been closed.');

            }
            ```
In the gax, `call.ts` call() doesn't catch this reject promise cause the hanging out.

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions