Open
Description
When query with cursor, following code will crash.
import { Pool, PoolClient, escapeIdentifier } from 'pg';
import Cursor from 'pg-cursor';
const dbConfig = parse('postgresql://postgres@localhost/postgres');
const pgPool = new Pool({
host: dbConfig.host,
port: Number(dbConfig.port),
user: dbConfig.user,
database: dbConfig.database,
max: 10,
idleTimeoutMillis: 30000,
statement_timeout: 3000,
connectionTimeoutMillis: 3000,
});
let client = await pgPool.connect();
console.log(`client-${id} connected`);
client.on('error', (err) => {
console.error(`client error: ${err}`);
});
client.on('end', () => {
console.log(`client end`);
});
const cursor = client.query(new Cursor('select 1'));
await new Promise(resolve=>setTimeout(resolve, 5000));
<path-to-my-project>\node_modules\pg\lib\client.js:561
queryCallback(error)
^
source-map-support.js:722
TypeError: queryCallback is not a function
at Timeout._onTimeout (<path-to-my-project>\node_modules\pg\lib\client.js:561:9)
at listOnTimeout (node:internal/timers:569:17)
at processTimers (node:internal/timers:512:7)
source-map-support.js:726
Process exited with code 1
source code that throws:
node-postgres/packages/pg/lib/client.js
Lines 551 to 562 in 26ace0a
Metadata
Metadata
Assignees
Labels
No labels