Skip to content

Commit 7223518

Browse files
authored
fix: fix vs2026 ICE compatibility (#1739)
* fix: vs2026 ICE compatibility * deps: conditionally install node-gyp for vs2026 * fixup! increase CI timeout-minutes to 60
1 parent 13c28f6 commit 7223518

4 files changed

Lines changed: 48 additions & 2 deletions

File tree

‎.github/workflows/ci-win.yml‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ permissions:
1010

1111
jobs:
1212
test:
13-
timeout-minutes: 30
13+
timeout-minutes: 60
1414
strategy:
1515
fail-fast: false
1616
matrix:
@@ -60,6 +60,13 @@ jobs:
6060
- name: Install dependencies
6161
run: |
6262
npm install
63+
# node-gyp@12 (from package.json) supports Visual Studio 2026, but only
64+
# node-gyp@13 emits the linker options that Node.js 26 builds require
65+
# (older node-gyp trips LNK1117 on '/opt:lldltojobs'). Upgrade in place for
66+
# Node.js >= 26; other versions keep node-gyp@12.
67+
- name: Use node-gyp@13 for Node.js >= 26
68+
if: matrix.node-version == '26.x'
69+
run: npm install --no-save node-gyp@13
6370
- name: npm test
6471
shell: bash
6572
run: |

‎.github/workflows/ci.yml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ permissions:
1010

1111
jobs:
1212
test:
13-
timeout-minutes: 30
13+
timeout-minutes: 60
1414
strategy:
1515
fail-fast: false
1616
matrix:
@@ -55,6 +55,11 @@ jobs:
5555
- name: Install dependencies
5656
run: |
5757
npm install
58+
# Node.js >= 26 requires node-gyp@13; older versions keep node-gyp@12
59+
# (from package.json).
60+
- name: Use node-gyp@13 for Node.js >= 26
61+
if: matrix.node-version == '26.x'
62+
run: npm install --no-save node-gyp@13
5863
- name: npm test
5964
run: |
6065
if [ "${{ matrix.api_version }}" = "experimental" ]; then

‎napi-inl.h‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4681,48 +4681,71 @@ template <typename T>
46814681
template <typename InstanceWrap<T>::InstanceVoidMethodCallback method>
46824682
inline ClassPropertyDescriptor<T> InstanceWrap<T>::InstanceMethod(
46834683
const char* utf8name, napi_property_attributes attributes, void* data) {
4684+
#ifdef _MSC_VER
4685+
// MSVC (as of v145 / Visual Studio 2026) raises an internal compiler error
4686+
// (C1001) when a pointer-to-member-function is used as a non-type template
4687+
// parameter, as the static compile-time dispatch below does. On MSVC, fall
4688+
// back to the runtime overload, which passes `method` as a value instead.
4689+
return InstanceMethod(utf8name, method, attributes, data);
4690+
#else
46844691
napi_property_descriptor desc = napi_property_descriptor();
46854692
desc.utf8name = utf8name;
46864693
desc.method = details::TemplatedInstanceVoidCallback<T, method>;
46874694
desc.data = data;
46884695
desc.attributes = attributes;
46894696
return desc;
4697+
#endif
46904698
}
46914699

46924700
template <typename T>
46934701
template <typename InstanceWrap<T>::InstanceMethodCallback method>
46944702
inline ClassPropertyDescriptor<T> InstanceWrap<T>::InstanceMethod(
46954703
const char* utf8name, napi_property_attributes attributes, void* data) {
4704+
#ifdef _MSC_VER
4705+
// See the note in the InstanceMethod overload above.
4706+
return InstanceMethod(utf8name, method, attributes, data);
4707+
#else
46964708
napi_property_descriptor desc = napi_property_descriptor();
46974709
desc.utf8name = utf8name;
46984710
desc.method = details::TemplatedInstanceCallback<T, method>;
46994711
desc.data = data;
47004712
desc.attributes = attributes;
47014713
return desc;
4714+
#endif
47024715
}
47034716

47044717
template <typename T>
47054718
template <typename InstanceWrap<T>::InstanceVoidMethodCallback method>
47064719
inline ClassPropertyDescriptor<T> InstanceWrap<T>::InstanceMethod(
47074720
Symbol name, napi_property_attributes attributes, void* data) {
4721+
#ifdef _MSC_VER
4722+
// See the note in the InstanceMethod overload above.
4723+
return InstanceMethod(name, method, attributes, data);
4724+
#else
47084725
napi_property_descriptor desc = napi_property_descriptor();
47094726
desc.name = name;
47104727
desc.method = details::TemplatedInstanceVoidCallback<T, method>;
47114728
desc.data = data;
47124729
desc.attributes = attributes;
47134730
return desc;
4731+
#endif
47144732
}
47154733

47164734
template <typename T>
47174735
template <typename InstanceWrap<T>::InstanceMethodCallback method>
47184736
inline ClassPropertyDescriptor<T> InstanceWrap<T>::InstanceMethod(
47194737
Symbol name, napi_property_attributes attributes, void* data) {
4738+
#ifdef _MSC_VER
4739+
// See the note in the InstanceMethod overload above.
4740+
return InstanceMethod(name, method, attributes, data);
4741+
#else
47204742
napi_property_descriptor desc = napi_property_descriptor();
47214743
desc.name = name;
47224744
desc.method = details::TemplatedInstanceCallback<T, method>;
47234745
desc.data = data;
47244746
desc.attributes = attributes;
47254747
return desc;
4748+
#endif
47264749
}
47274750

47284751
template <typename T>
@@ -4768,27 +4791,37 @@ template <typename InstanceWrap<T>::InstanceGetterCallback getter,
47684791
typename InstanceWrap<T>::InstanceSetterCallback setter>
47694792
inline ClassPropertyDescriptor<T> InstanceWrap<T>::InstanceAccessor(
47704793
const char* utf8name, napi_property_attributes attributes, void* data) {
4794+
#ifdef _MSC_VER
4795+
// See the note in the InstanceMethod overload above.
4796+
return InstanceAccessor(utf8name, getter, setter, attributes, data);
4797+
#else
47714798
napi_property_descriptor desc = napi_property_descriptor();
47724799
desc.utf8name = utf8name;
47734800
desc.getter = details::TemplatedInstanceCallback<T, getter>;
47744801
desc.setter = This::WrapSetter(This::SetterTag<setter>());
47754802
desc.data = data;
47764803
desc.attributes = attributes;
47774804
return desc;
4805+
#endif
47784806
}
47794807

47804808
template <typename T>
47814809
template <typename InstanceWrap<T>::InstanceGetterCallback getter,
47824810
typename InstanceWrap<T>::InstanceSetterCallback setter>
47834811
inline ClassPropertyDescriptor<T> InstanceWrap<T>::InstanceAccessor(
47844812
Symbol name, napi_property_attributes attributes, void* data) {
4813+
#ifdef _MSC_VER
4814+
// See the note in the InstanceMethod overload above.
4815+
return InstanceAccessor(name, getter, setter, attributes, data);
4816+
#else
47854817
napi_property_descriptor desc = napi_property_descriptor();
47864818
desc.name = name;
47874819
desc.getter = details::TemplatedInstanceCallback<T, getter>;
47884820
desc.setter = This::WrapSetter(This::SetterTag<setter>());
47894821
desc.data = data;
47904822
desc.attributes = attributes;
47914823
return desc;
4824+
#endif
47924825
}
47934826

47944827
template <typename T>

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@
424424
"eslint": "^9.13.0",
425425
"fs-extra": "^11.1.1",
426426
"neostandard": "^0.12.0",
427+
"node-gyp": "^12.4.0",
427428
"pre-commit": "^1.2.2",
428429
"semver": "^7.6.0"
429430
},

0 commit comments

Comments
 (0)