Fix Windows CI against Visual Studio 2026 and Node 26 - #1001
Open
X-Guardian wants to merge 1 commit into
Open
X-Guardian wants to merge 1 commit into
X-Guardian wants to merge 1 commit into
Conversation
|
OX Security reviewed this pull request — nothing to fix.
Branch |
X-Guardian
force-pushed
the
chore/fix-vs2026
branch
from
September 23, 2026 15:44
6d99e98 to
a669b53
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #998, which has the diagnosis:
windows-latestnow ships Visual Studio 2026, the tests hardcode--msvs_version=2022, and node-gyp only recognises VS 18 from v12 onwards.Changes
Drop the hardcoded
--msvs_version=2022fromtest/run.util.jsand let node-gyp detect the toolchain. Each runner image carries exactly one Visual Studio, so there is nothing to disambiguate: the flag only ever asserted a year that happened to match. It was not deliberate either. It began as--msvs_version=2015with the comment "since that is more edge case than 2013", and the2022value arrived via a mechanical bump in #707, needing an edit on every image change since.Add
windows-2022to both matrices. VS 2022 remains widely used and is the image GitHub directs users to when they need it, so it is worth covering alongside VS 2026 rather than testing only the newest toolchain.Add
scripts/upgrade-node-gyp.js, run on Windows vianpm run upgrade-node-gyp. It reads the version of the node-gyp that node-pre-gyp would invoke and installs a newer one only when that version predates VS 2026 support. Keying off the resolved node-gyp rather than the Node version matters because the matrix uses floating aliases:lts/-1is Node 22 today and becomes Node 24 when Node 26 enters LTS, at which point the script finds node-gyp 12 and does nothing.Skip one test where npm's own node-gyp is too old. npm runs install hooks against the copy it bundles, ignoring
npm_config_node_gypwhether set by environment variable,.npmrc, or--node-gyp. Where that copy cannot detect the installed Visual Studio,app1 passes --nodedir down to node-gyp via npmfails at VS detection before--nodediris read, so the assertion cannot be made. The sibling test covers the same forwarding via node-pre-gyp directly.Regenerate
abi_crosswalk.jsonthrough Node 26.10.0. Thelatestmatrix entry now resolves to Node 26, which failed withUnsupported target version: 26.9.0on every platform.node-gyp resolution in the tests
npm resets
npm_config_node_gypto its bundled copy whenever it runs a script, so a value exported by the upgrade step does not survivenpm test. The script therefore exportsNPG_TEST_NODE_GYP, a name npm leaves alone, andtest/run.util.jspasses it to each child asnpm_config_node_gyp, which node-pre-gyp already reads.This keeps the change out of the published package:
lib/util/compile.jsgains one line exportingwhich_node_gyp, so the upgrade script resolves node-gyp exactly as the build does. No resolution behaviour changes for consumers.Result
15 jobs in
ci.ymland 12 ins3-bucket.yml, with Windows covered on both toolchains:lts/-1lts/*latestNon-Windows jobs are unaffected. The upgrade step is guarded by
runner.os == 'Windows', and--msvs_versionwas only ever passed under awin32check.Notes for reviewers
INSTALL_VERSIONrather than tracking@latest, so CI does not silently follow new node-gyp releases.--no-save. A global install is not picked up:which_node_gypresolves throughnpm_config_node_gyp, thenrequire.resolve, then npm's bundled copy, none of which see the global prefix. Verified by installing node-gyp 13.0.2 globally and confirming resolution still returned npm's bundled copy.s3-bucket.ymlalso picks up a fix for${{ matrix.node }}references left behind by the matrix key rename in chore: replace the end-of-life Node 20 in the CI test matrices #999. Its tests are skipped whenS3_BUCKETis unset, so the Windows changes there are untested in forks.npm run update-crosswalkremains commented out inci.yml, so the crosswalk will go stale again on the next Node release.