Skip to content

Conversation

tmm1
Copy link
Contributor

@tmm1 tmm1 commented Jun 3, 2025

improves reliability of builds on windows

includes nodejs/node-gyp#3113 and nodejs/node-gyp#3112

cc @deepak1556 @joaomoreno

improves reliability of builds on windows

includes nodejs/node-gyp#3113 and nodejs/node-gyp#3112
@deepak1556 deepak1556 added this to the June 2025 milestone Jun 4, 2025
@deepak1556
Copy link
Collaborator

Thanks for the fixes in upstream! Couple of notes,

  1. This only affects the node-gyp used to fetch headers on windows
    installHeaders();
    , we should either have node-gyp version locked in a couple of places like remote/package.json, build/package.json, package.json to have the concurrent compilation error addressed or we could also configure npm_config_node_gyp in postinstall.js to have it take affect for all directories except root (this still needs to lock the version in package.json)
  2. The repo does not accept package-lock changes from external contributors, I will amend the lockfile changes so the PR checks can pass.

@tmm1
Copy link
Contributor Author

tmm1 commented Jun 6, 2025

  1. This only affects the node-gyp used to fetch headers on windows

Ah good catch

  1. we should either have node-gyp version locked in a couple of places like remote/package.json, build/package.json, package.json

Seems like pinning is not enough, because npm will only use its own bundled version

https://github.com/nodejs/node-gyp/blob/main/docs/Updating-npm-bundled-node-gyp.md

@deepak1556
Copy link
Collaborator

deepak1556 commented Jun 7, 2025

Seems like pinning is not enough, because npm will only use its own bundled version

There is npm_config_node_gyp to force an alternative version which we could leverage in the postinstall step for all directories except the root (need another way for this).

Maybe for root we can force the value via .npmrc and point to the version that gets installed into build/npm/gyp which happens as part of preinstall.

@tmm1
Copy link
Contributor Author

tmm1 commented Jun 8, 2025

Thanks for the tips. It seems to be working in my tests.

@tmm1 tmm1 changed the title chore: bump node-gyp on windows to 11.2.0 chore: bump node-gyp to 11.2.0 Jun 8, 2025
@deepak1556
Copy link
Collaborator

Changes look good to me, the [Prevent package-lock.json changes in PRs / Prevent package-lock.json changes in PRs check relies on the PR author rather than commit author so I cannot make it pass. Let me open a PR with your changes cherry-picked, thanks!

@deepak1556
Copy link
Collaborator

Closing in favor of #250981

@deepak1556 deepak1556 closed this Jun 9, 2025
@tmm1
Copy link
Contributor Author

tmm1 commented Jun 11, 2025

I hit this again today (happens so intermittently it is hard to test), so I guess it's still not quite fixed.

npm error path D:\a\_work\1\s\vscode\node_modules\@vscode\windows-process-tree
npm error command failed
npm error command C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm error C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(382,5): error MSB3491: Could not write lines to file "Release\obj\node_addon_api_except\node_add.A3690B4C.tlog\node_addon_api_except.lastbuildstate". The process cannot access the file 'D:\a\_work\1\s\vscode\node_modules\@vscode\node-addon-api\Release\obj\node_addon_api_except\node_add.A3690B4C.tlog\node_addon_api_except.lastbuildstate' because it is being used by another process. [D:\a\_work\1\s\vscode\node_modules\@vscode\node-addon-api\node_addon_api_except.vcxproj]
npm error gyp info it worked if it ends with ok
npm error gyp info using node-gyp@10.1.0
npm error gyp info using node@20.18.2 | win32 | x64

This is happening from the root it seems, so the .npmrc override isn't working? Maybe need to add the build/npm/gyp/node_modules/.bin to PATH to be able to catch this node-gyp rebuild invocation?

@deepak1556
Copy link
Collaborator

Ah I misread the line in .npmrc should have been node_gyp instead of npm_config_node_gyp that would get set on the environment via https://github.com/npm/cli/blob/0ad1444d76b0b68e4a4d48d7f22ebd4cd0d0e850/workspaces/config/lib/index.js#L240-L272, there is also another way via --node-gyp cli option to npm we could force the value https://github.com/npm/cli/blob/0ad1444d76b0b68e4a4d48d7f22ebd4cd0d0e850/workspaces/config/lib/set-envs.js#L105-L106

Can you try either and see if that helps.

@tmm1
Copy link
Contributor Author

tmm1 commented Jun 12, 2025

I will try. On failures I see the banner with using node-gyp@10.1.0. Do you know if there's a way to print the version otherwise to test?

❯ node build/npm/gyp/node_modules/node-gyp/bin/node-gyp.js --version
v11.2.0

❯ npm_config_node_gyp="node build/npm/gyp/node_modules/node-gyp/bin/node-gyp.js" npm run node-gyp --version
10.8.2

@tmm1
Copy link
Contributor Author

tmm1 commented Jun 12, 2025

Ahh some of the code you mentioned wasn't introduced until npm 11.3 npm/cli@b306d25

@tmm1
Copy link
Contributor Author

tmm1 commented Jun 12, 2025

The env var set for ./remote isn't working either (for the same reason, too old npm?):

npm error gyp ERR! cwd /opt/azure-devops-agent/_work/1/s/vscode/remote/node_modules/node-pty
npm error gyp ERR! node -v v20.18.2
npm error gyp ERR! node-gyp -v v10.1.0

@deepak1556
Copy link
Collaborator

hmm for remote we are configuring env variable which has been supported for a long time in npm, it must be something else.

@tmm1
Copy link
Contributor Author

tmm1 commented Jun 12, 2025

Thanks, you're right the remote failure above was unrelated. It was happening from npm being run directly in that dir.

I will update .npmrc and watch builds over a few days.

@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Jul 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants