Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

fix: prevent unhandled promise rejections while creating session#1332

Merged
skuruppu merged 3 commits intogoogleapis:masterfrom
laljikanjareeya:unhandled-promise-exception
Apr 6, 2021
Merged

fix: prevent unhandled promise rejections while creating session#1332
skuruppu merged 3 commits intogoogleapis:masterfrom
laljikanjareeya:unhandled-promise-exception

Conversation

@laljikanjareeya
Copy link
Copy Markdown
Contributor

@laljikanjareeya laljikanjareeya commented Apr 2, 2021

Here is the different scenarios on how it handles the exception.

Non existing Table:
5 NOT_FOUND: Table not found: fake-table-name
Properly Handles the exception.

Non existing Database:
5 NOT_FOUND: Database not found: projects/existing-project/instances/existing-instance/databases/fake-database-id
Properly Handles the exception.

Non existing Instance:
5 NOT_FOUND: Instance not found: projects/existing-project/instances/fake-instance-id
Properly Handles the exception.

Non existing Project:
7 PERMISSION_DENIED: Caller is missing IAM permission spanner.sessions.create on resource projects/fake-projectId/instances/existing-instance-id/databases/existing-database-id.
It gives the error as well as throws UnhandledPromiseRejectionWarning exception.

While creating the session if Project doesn't exists it gives the above error as well has throws the UnhandledPromiseRejectionWarning exception.

Propose Implementation:
stop re-emitting the spanner.sessions.create permission error.

Fixes #1319

It also triggers two more unhandled promise rejection:

  1. Could not load the default credentials while default credentials not set.
  2. Unable to detect a Project Id in the current environment while projectId not set.

I have added separate issue #1333 for same.

@laljikanjareeya laljikanjareeya requested review from a team April 2, 2021 07:35
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Apr 2, 2021
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/nodejs-spanner API. label Apr 2, 2021
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2021

Codecov Report

Merging #1332 (e6f6b3e) into master (d851858) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1332   +/-   ##
=======================================
  Coverage   98.60%   98.60%           
=======================================
  Files          23       23           
  Lines       21923    21942   +19     
  Branches     1226     1229    +3     
=======================================
+ Hits        21617    21636   +19     
  Misses        297      297           
  Partials        9        9           
Impacted Files Coverage Δ
src/session-pool.ts 99.83% <100.00%> (+<0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d851858...e6f6b3e. Read the comment docs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: spanner Issues related to the googleapis/nodejs-spanner API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

triggers unhandled promise rejection that we cannot prevent

2 participants