triggers unhandled promise rejection that we cannot prevent
See original GitHub issueEnvironment details
- OS: linux
- Node.js version: 10
- npm version: 7
@google-cloud/spanner
version: 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
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
What is an unhandled promise rejection? - Stack Overflow
TLDR: A promise has resolve and reject , doing a reject without a catch to handle it is deprecated, so you will have...
Read more >What is UnhandledPromiseRejectionWarning
The Promise.reject() method returns a Promise object that is rejected with a given reason. The unhandledrejection event is sent to the global scope...
Read more >Terminate process on unhandled promise rejection #20392
We want to allow people to turn off unhandled rejection detection completely for language semantics. We can't just turn off the current " ......
Read more >Unhandled Promise Rejections in Node.js - The Code Barbarian
If you want to suppress the unhandled promise rejection warning, all you need to do is call . catch() on the promise with...
Read more >Creating a JavaScript promise from scratch, Part 7: Unhandled ...
If the rejection handler is added after the browser has triggered unhandledrejection , then a rejectionhandled event is triggered to let you ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@gsouf I think it would mean that the first batch of sessions are created when executing the first request so there will be a small increase in latency for the first request. But sessions are created in batches so for subsequent requests, it shouldn’t be an issue.
In any case, #1332 will handle the specific case you came across in your first comment so you won’t need to use
{min: 0}
.@AVaksman would you please be able to take a look?