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

Database#close(): Promise doesn't handle SessionPool#close() properly #1828

Open
nabeix opened this issue Mar 21, 2023 · 1 comment
Open
Assignees
Labels
api: spanner Issues related to the googleapis/nodejs-spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@nabeix
Copy link

nabeix commented Mar 21, 2023

Database#close() has Promise interface.

https://github.com/googleapis/nodejs-spanner/blob/main/src/database.ts#L627

But I found that await database.close() or database.close().then() doesn't wait SessonPool#close() properly.

this.pool_.close(callback!);

I think this code should be handle callback as followings:

if (typeof callback === 'function') {
  this.pool_.close(callback);
} else {
  return new Promise((resolve, reject) => {
    callback(err => {
      if (err) {
        reject(err);
      }  else {
        resolve();
      }
    });
  });
}
@nabeix nabeix added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Mar 21, 2023
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/nodejs-spanner API. label Mar 21, 2023
@surbhigarg92 surbhigarg92 self-assigned this Mar 23, 2023
@surbhigarg92
Copy link
Contributor

Hi @nabeix Can you please share an example or repro steps for us to reproduce this issue ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/nodejs-spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants