This repository was archived by the owner on Mar 4, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 113
This repository was archived by the owner on Mar 4, 2026. It is now read-only.
triggers unhandled promise rejection that we cannot prevent #1319
Copy link
Copy link
Closed
Labels
api: spannerIssues related to the googleapis/nodejs-spanner API.Issues related to the googleapis/nodejs-spanner API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-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.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- OS: linux
- Node.js version: 10
- npm version: 7
@google-cloud/spannerversion: 5.5.0
Steps to reproduce
Create this js file and run it (no need for a spanner instance to be setup).
This sample will try to connect to spanner with an unexisting instance name just because it's simpler to simulate the error this way, but it seems to occur with any error.. It will result in an error when doing the insert. The error will be caught in the catch statement, but it will also throw an unhandled promise rejection. The promise rejection that cannot be caught without unhandledRejection event is not a desired behavior for a 3rd party library.
const {Spanner} = require("@google-cloud/spanner");
run();
async function run() {
try {
const spanner = new Spanner({
projectId: 'somebrokenprojectid',
});
const instance = spanner.instance("somebrokeninstance");
const database = instance.database("somedb");
const table = database.table("sometable");
console.log('insert data');
await table.insert([{somekey: "somevalue"}]);
} catch (e) {
console.error('caught exception', e.message)
}
}
Thanks
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api: spannerIssues related to the googleapis/nodejs-spanner API.Issues related to the googleapis/nodejs-spanner API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-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.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.