Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Cursor crash when reaching query_timeout

Đang mở
#3,475 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, node.js, postgresql
Lĩnh vực
backend, databases

Hướng nghiên cứu

Bắt đầu với packages/pg/lib/client.js tại các dòng được liên kết 551-562 và tái hiện lỗi bằng truy vấn Cursor cùng cấu hình timeout được cung cấp. Theo dõi cách callback timeout xử lý truy vấn Cursor; được xem là hoàn tất khi việc đạt đến timeout không còn ném ra TypeError được báo cáo và client vẫn nhất quán với hành vi cursor dự kiến.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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:
https://github.com/brianc/node-postgres/blob/26ace0ac8f1bbf0a9ac26025a36ab15e4c6fa4af/packages/pg/lib/client.js#L551-L562

Ngôn ngữ chính
JavaScript
Star
13.2k
Fork
1.4k
Merge trung bình
6 ngày 15 giờ
Pull request đã merge (30 ngày)
6

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của brianc/node-postgres

Tất cả issue của brianc/node-postgres

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.