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.

cancel active query doesn't work with js bindings

See original GitHub issue

Cancelling long running query, doesn’t work with js bindings, though with native bindings it works. Example:

pg = require('pg');

var client = new pg.Client(...);

client.on('notice', function(msg) {
  console.log("custom notice: " + msg);
});

client.connect(function(err){

    if (err){
        console.log(err);
    }

    var query_text = "select pg_sleep(20);";
    var query = client.query(query_text, function(err, result){
        if (err){
            console.log(err);
        }
    });

    console.log("wating for 5 seconds");
    setInterval(function(){
        console.log("canceling query");
        client.cancel(query);
    }, 5000);

});

After issuing cancel the query keeps running, while with native bindings it returns error as expected:

wating for 5 seconds
canceling query
{ [Error: ERROR:  canceling statement due to user request
]
  severity: 'ERROR',
  sqlState: '57014',
  messagePrimary: 'canceling statement due to user request',
  sourceFile: 'postgres.c',
  sourceLine: '3009',
  sourceFunction: 'ProcessInterrupts' }

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:5
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vitaly-tcommented, Apr 22, 2016

Does it still doesn’t work? 🎱

0reactions
mhkellercommented, Sep 28, 2018

Looks like #1392 has stalled. Is this on the roadmap? I’m also not sure how you’d implement the above using await via the promises API since your code wouldn’t reach the setTimeout bit. Any thoughts @boromisp?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Promise with query binding doesnt end - Stack Overflow
I having this function query in my module mysqlFunction in NodeJs. The functions work without a problem when the query hasn't had binding,...
Read more >
The 10 Most Common JavaScript Issues Developers Face
If you need help figuring out why your JavaScript isn't working, consult this list of the 10 most common JavaScript issues from a...
Read more >
Stop using Knex.js. Using SQL query builder is an…
To solve this problem, you first need to answer “What query do I need to execute to get this result?” You might even...
Read more >
Don't Block the Event Loop (or the Worker Pool) - Node.js
If a thread is taking a long time to execute a callback (Event Loop) or a task (Worker), we call it "blocked". While...
Read more >
bq command-line tool reference | BigQuery - Google Cloud
This flag applies only to commands that create jobs: cp , extract , load , and query . If you don't use the...
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