process.exit before console buffer flushed in Windows
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
- 38/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript
- Lĩnh vực
- cli, operating-systems, testing
Hướng nghiên cứu
Bắt đầu trong bin/nodeunit, quanh các dòng 128-132, đặc biệt là process.exit(1) ở dòng 130, và tái hiện vấn đề bằng tests.js được cung cấp trên Cygwin. Xác nhận rằng các lần chạy thất bại hiển thị toàn bộ đầu ra của console nhưng vẫn trả về mã thoát 1; workaround hiện có cung cấp hành vi mong đợi để kiểm tra.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Symptoms
If any test fails, not all the console output is shown (console output is truncated).
Problem does not show up in standard Windows cmd, but does show up if tests are run from Cygwin or within Sublime Text build system. In Cygwin, if the output is piped to a file instead of being displayed on the console then all the results show in the file, even though they did not show in the console when not piped.
Environment
- nodeunit 0.9.0,
- node 0.10.17
- Windows 7
Minimal Example
I have the following test file, tests.js:
for (var i = 0; i < 30; i++)
console.log('' + i);
exports.dummy = function(test) {
test.fail();
test.done();
}
Running from Cygwin, the result is:
$ nodeunit tests.js
0
(I.e., only the first console.log appears). But if I remove the test.fail line then all the output appears.
Cause
My guess of the cause is given in the title. It appears that under different circumstances, sometimes the node console is asynchronous (perhaps due to the way Windows pipes work, I'm not sure), and doesn't flush the output after every write. When a test fails, line 130 in nodeunit/nodeunit process.exit(1); seems to recognize the error and exit the process, but process.exit does not seem to always wait for the console output to be received by the terminal. To confirm this hypothesis, if I remove the process.exit line, then the output is displayed correctly.
Solution
A work-around seems to be to change lines 128-132 to the following:
testrunner.run(files, options, function(err) {
if (err) {
process.on('exit', function() {
process.exit(1);
});
}
});
This seems to produce the correct error code for the process and also show all the output. I don't know if there are any other side effects of not ending the process immediately in the callback function.
- Ngôn ngữ chính
- JavaScript
- Star
- 1.9k
- Fork
- 359
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của caolan/nodeunit
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 42/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
Tất cả issue của caolan/nodeunit
Issue tương tự
-
area:plugins enhancement platform:vscode
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
anthropics/claude-code#103166 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add: Kids Zone LogoĐang mởcheck:failed logos:add
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
-
[workshop-sim] Improve: Add verifiable checkpoint and bridge to Step 5 (What Are Agentic Workflows?)Đang mởfeedback simulation workshop
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
githubnext/gh-aw-workshop#4715 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
getComputedStyle ignores a rule whose selector list contains a pseudo-element (regression in 30.x)Có thể đã có người làm @chiragjangiir đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 1 ngày
-
external-plugin external-plugin-canvas needs-review:MEDIUM ready-for-review
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
github/awesome-copilot#5153 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày