Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error not being thrown when statement cancelled due to timeout #867

Closed
0x-jj opened this issue Feb 21, 2023 · 5 comments
Closed

Error not being thrown when statement cancelled due to timeout #867

0x-jj opened this issue Feb 21, 2023 · 5 comments
Assignees

Comments

@0x-jj
Copy link

0x-jj commented Feb 21, 2023

Expected behavior

An error is thrown when a statement is cancelled due to a timeout

Actual behavior

No error is thrown

Steps to reproduce

try {
await idb.tx((t) => {
      const lockTimeout = t.none("SET LOCAL lock_timeout = '2s'");
      const q = t.none(query); // This causes an ERROR to be logged by the db and the statement is cancelled due to the lock timeout
      return t.batch([lockTimeout, q]);
    });
} catch (err) {
// No error is thrown
console.log(err)
}

Environment

  • Version of pg-promise: ^11.2.0
  • OS type (Linux/Windows/Mac): Linux, aws lambda
  • Version of Node.js: 16
@0x-jj 0x-jj added the triage To be investigated label Feb 21, 2023
@vitaly-t
Copy link
Owner

vitaly-t commented Feb 21, 2023

If you're not getting an error, it means that the underlying driver doesn't throw one. Whether it is a bug in the driver or something else, it is a little out of scope here. I suggest you check with the driver, and open a ticket there.

@vitaly-t
Copy link
Owner

vitaly-t commented Feb 21, 2023

This addition made it into the latest version. So if you are really using 11.2 (i'd check it), then it should work, somehow. Or maybe it is a separate feature, I'm not sure, you'll need to research.

@vitaly-t vitaly-t added out-of-scope and removed triage To be investigated labels Feb 21, 2023
@0x-jj
Copy link
Author

0x-jj commented Feb 21, 2023

This addition made it into the latest version. So if you are really using 11.2 (i'd check it), then it should work, somehow. Or maybe it is a separate feature, I'm not sure, you'll need to research.

Interesting

I'm definitely on 11.2, though I don't see the lock_timeout supported when constructing the pgpromise config

Typescript says Object literal may only specify known properties, and 'lock_timeout' does not exist in type 'IConnectionParameters<IClient>

Is this just a typing thing and you expect it to still be passed down to the driver?

import PgPromise from 'pg-promise';

const pgp = PgPromise();

export const db = pgp({
  connectionString: config.databaseUrl,
  keepAlive: true,
  max: 10,
  connectionTimeoutMillis: 30 * 1000,
  query_timeout: 5 * 60 * 1000,
  allowExitOnIdle: true,
  lock_timeout: 5 * 60 * 1000, // has typescript error
});

@vitaly-t
Copy link
Owner

vitaly-t commented Feb 21, 2023

Is this just a typing thing and you expect it to still be passed down to the driver?

It was indeed an omission in TypeScript declaration, patched in v11.3.0.

@0x-jj
Copy link
Author

0x-jj commented Feb 22, 2023

Is this just a typing thing and you expect it to still be passed down to the driver?

It was indeed an omission in TypeScript declaration, patched in v11.3.0.

Great, thanks!

@0x-jj 0x-jj closed this as completed Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants