Skip to content

Commit e68db81

Browse files
committed
Try to patch node instead of skipping the test
1 parent cb278bc commit e68db81

File tree

3 files changed

+62
-7
lines changed

3 files changed

+62
-7
lines changed

.evergreen/install-node-source.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ pushd "${NODE_JS_SOURCE_PATH}"
5555
# patch directory
5656
patch -p1 < "${ROOT_DIR}/scripts/nodejs-patches/001-configure-bz2.patch"
5757

58+
if [[ "$NODE_JS_VERSION" == "22"* ]]; then
59+
patch -p1 < "${ROOT_DIR}/scripts/nodejs-patches/005-win-almost-fix-race-detecting-esrch-in-uv-kill.patch"
60+
fi
61+
5862
./configure --prefix "${NODE_JS_INSTALL_DIR}"
5963

6064
ncpu=$(expr $(nproc 2> /dev/null || echo 5) - 1)

packages/e2e-tests/test/e2e.spec.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,13 +1059,6 @@ describe('e2e', function () {
10591059
});
10601060

10611061
it('reads and runs the vscode extension example playground', async function () {
1062-
if (
1063-
process.platform === 'win32' &&
1064-
process.versions.node.startsWith('22')
1065-
) {
1066-
// This test fails on Windows with node 22 likely due to https://github.com/nodejs/node/issues/51766
1067-
return this.skip();
1068-
}
10691062
createReadStream(
10701063
path.resolve(__dirname, 'fixtures', 'exampleplayground.js')
10711064
).pipe(shell.process.stdin);
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
diff --git a/deps/uv/src/win/process.c b/deps/uv/src/win/process.c
2+
index 4e94dee90e13eede63d8e97ddc9992726f874ea9..f46f34289e8e7d3a2af914d89e6164b751a3e47d 100644
3+
--- a/deps/uv/src/win/process.c
4+
+++ b/deps/uv/src/win/process.c
5+
@@ -1308,16 +1308,34 @@ static int uv__kill(HANDLE process_handle, int signum) {
6+
/* Unconditionally terminate the process. On Windows, killed processes
7+
* normally return 1. */
8+
int err;
9+
+ DWORD status;
10+
11+
if (TerminateProcess(process_handle, 1))
12+
return 0;
13+
14+
- /* If the process already exited before TerminateProcess was called,.
15+
+ /* If the process already exited before TerminateProcess was called,
16+
* TerminateProcess will fail with ERROR_ACCESS_DENIED. */
17+
err = GetLastError();
18+
- if (err == ERROR_ACCESS_DENIED &&
19+
- WaitForSingleObject(process_handle, 0) == WAIT_OBJECT_0) {
20+
- return UV_ESRCH;
21+
+ if (err == ERROR_ACCESS_DENIED) {
22+
+ /* First check using GetExitCodeProcess() with status different from
23+
+ * STILL_ACTIVE (259). This check can be set incorrectly by the process,
24+
+ * though that is uncommon. */
25+
+ if (GetExitCodeProcess(process_handle, &status) &&
26+
+ status != STILL_ACTIVE) {
27+
+ return UV_ESRCH;
28+
+ }
29+
+
30+
+ /* But the process could have exited with code == STILL_ACTIVE, use then
31+
+ * WaitForSingleObject with timeout zero. This is prone to a race
32+
+ * condition as it could return WAIT_TIMEOUT because the handle might
33+
+ * not have been signaled yet.That would result in returning the wrong
34+
+ * error code here (UV_EACCES instead of UV_ESRCH), but we cannot fix
35+
+ * the kernel synchronization issue that TerminateProcess is
36+
+ * inconsistent with WaitForSingleObject with just the APIs available to
37+
+ * us in user space. */
38+
+ if (WaitForSingleObject(process_handle, 0) == WAIT_OBJECT_0) {
39+
+ return UV_ESRCH;
40+
+ }
41+
}
42+
43+
return uv_translate_sys_error(err);
44+
@@ -1325,6 +1343,14 @@ static int uv__kill(HANDLE process_handle, int signum) {
45+
46+
case 0: {
47+
/* Health check: is the process still alive? */
48+
+ DWORD status;
49+
+
50+
+ if (!GetExitCodeProcess(process_handle, &status))
51+
+ return uv_translate_sys_error(GetLastError());
52+
+
53+
+ if (status != STILL_ACTIVE)
54+
+ return UV_ESRCH;
55+
+
56+
switch (WaitForSingleObject(process_handle, 0)) {
57+
case WAIT_OBJECT_0:
58+
return UV_ESRCH;

0 commit comments

Comments
 (0)