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

Engine: asynchronous code in the worker's publish causes events to be lost

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

Maintainer thường phản hồi trong vòng 1 ngày

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

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 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
Ít trao đổi
Công nghệ
node.js, typescript

Hướng nghiên cứu

Bắt đầu từ vòng lặp kích thước payload bất đồng bộ được giới thiệu trong #1366 và lần theo parentPort.postMessage trong quá trình worker tắt. Tái hiện các trường hợp về thứ tự và mất message được mô tả ở đây, sau đó xác minh rằng các event được phát ra rời worker theo đúng thứ tự và không bị loại bỏ khi task kết thúc.

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

Mô tả

DevX

Inside the engine, we run job code in a worker thread. The worker thread sends events out to the main engine process through parentPort.postMessage

In production right now this is synchronous. When the message is posted the payload is processed and sent out of the child worker. This ensures that messages leave the worker_thread in the same order that they were emitted from the runtime.

In #1366 we use an async loop to read the size of a payload before sending it. This async loop is causing two problems:

  1. It no longer guarantees that events will leave the worker thread in the same order as they're emitted, because of the async yield. If message a takes longer to process than message b, than message b might be piped through the port first.
  2. Some messages don't get emitted at all because the worker thread is shut down while the events are being processed. When we complete the task and exit the run, I don't think there's anyway to know that messages are still processing and waiting to be emitted.

I don't think this is affecting production, but it's a possible cause of #1072. What I'm worried about is that a message emitted with a large-ish payload, but the worker thread gets killed before that message is completed.

I'd sort of expect node.js to handle that for me and not exit the worker until the message has finished posting, but it's possible that we're exiting too soon (because of code or config in the engine).

Ngôn ngữ chính
TypeScript
Star
22
Fork
23
Merge trung bình
1 ngày 6 giờ
Pull request đã merge (30 ngày)
26

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

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

  • Có Dockerfile hoặc tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

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 OpenFn/kit

Tất cả issue của OpenFn/kit

Issue tương tự

Thêm issue về TypeScript

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.