question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

triggers unhandled promise rejection that we cannot prevent

See original GitHub issue

Environment 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:closed
  • Created 3 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
skuruppucommented, Apr 6, 2021

@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}.

1reaction
skuruppucommented, Mar 17, 2021

@AVaksman would you please be able to take a look?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found