Skip to content

Commit 2f35ed7

Browse files
author
vektor
committed
fix crash with async workers in napi addons
1 parent 88b849f commit 2f35ed7

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ jobs:
5555
uses: ilammy/setup-nasm@v1
5656
if: runner.os == 'Windows'
5757

58+
- name: Ensure MSVC Toolset 14.36.32532 is installed
59+
if: runner.os == 'Windows'
60+
shell: powershell
61+
run: |
62+
$vsPath = & '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"' -latest -property installationPath
63+
if (-not $vsPath) {
64+
Write-Error "Visual Studio installation not found."
65+
exit 1
66+
}
67+
$msvcDir = Join-Path $vsPath "VC\Tools\MSVC\14.36.32532"
68+
if (-Not (Test-Path $msvcDir)) {
69+
Write-Host "MSVC toolset 14.36.32532 not found. Attempting installation..."
70+
& "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" modify --installPath $vsPath --add Microsoft.VisualStudio.Component.VC.14.36.17.6.x86.x64 --quiet --wait
71+
} else {
72+
Write-Host "MSVC toolset 14.36.32532 is already installed."
73+
}
74+
5875
- name: Build
5976
if: runner.os == 'Windows'
6077
shell: bash

patches/async_addon.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git forkSrcPrefix/src/node_api.cc forkDstPrefix/src/node_api.cc
2+
index a019a1826c6ce72a5f05d0bee01ece2089126b09..4694d3ad271a7a46e28f4c9bf4b8266bb0eca56e 100644
3+
--- forkSrcPrefix/src/node_api.cc
4+
+++ forkDstPrefix/src/node_api.cc
5+
@@ -1201,7 +1201,7 @@ class Work : public node::AsyncResource, public node::ThreadPoolWork {
6+
// Establish a handle scope here so that every callback doesn't have to.
7+
// Also it is needed for the exception-handling below.
8+
v8::HandleScope scope(_env->isolate);
9+
-
10+
+ v8::Context::Scope context_scope(_env->context());
11+
CallbackScope callback_scope(this);
12+
13+
_env->CallbackIntoModule<true>([&](napi_env env) {

0 commit comments

Comments
 (0)