The `abort` event on nodejs is deprecated

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

@akashbirajdar04 đang làm issue này rồi.

Từ ngày 30/4/2026.

  • #4579 của @sapirbaruch — đã đóng, không merge

Đá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
52/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
node.js
Lĩnh vực
backend, networking

Hướng nghiên cứu

Bắt đầu với hapi/lib/request.js ở dòng 328 và tài liệu về abort-event của Node.js http.ClientRequest. Theo dõi Request.active() và tái hiện hành vi bằng một request hapi bị trì hoãn trong khi liên tục refresh trình duyệt. Hoàn tất khi các request bị ngắt kết nối được phát hiện và hủy một cách đáng tin cậy bất chấp event đã deprecated, đồng thời hành vi này được bao phủ bởi các kiểm tra hồi quy phù hợp.

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

Mô tả

bug
Runtime

node.js

Runtime version

24

Module version

21.4.4

Last module version without issue

Node 17

Used with

hapi application

Any other relevant information

The Request.active() function always returns true.

The abort event on NodeJS's http.ClientRequest has been deprecated since NodeJS v17, and hapi/lib/request.js is depending on that function.

[1] https://github.com/hapijs/hapi/blob/master/lib/request.js#L328
[2] https://nodejs.org/api/http.html#event-abort

What are you trying to achieve or the steps to reproduce?

When spamming my F5 key on my browser with a request with an intentional delay, the request never got cancelled, and active() always returned true.

What was the result you got?

The requests were never cancelled.

What result did you expect?

I wrote a small plugin to work around the issue:

export const plugin: Plugin<object> = {
  name: 'earlyCancel',
  register(server) {
    server.ext('onPreAuth', (request, tk) => {
      request.app.disconnected = false;
      request.raw.req.on('close', () => {
        if (!request.raw.res.writableEnded) {
          request.app.disconnected = true;
        }
      });
      return tk.continue;
    });
  },
};

And verify that when spamming F5, I was able to get some requests to be cancelled.

Ngôn ngữ chính
JavaScript
Star
14.8k
Fork
1.4k
Merge trung bình
14 phút
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

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 hapijs/hapi

Tất cả issue của hapijs/hapi

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.