Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .evergreen/node-gyp-bug-workaround.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash

# This is a workaround for a node-gyp bug that has not fully been investigated
# due to problems reproducing it outside of CI environments (even though it
# occurs both in evergreen and github actions).
# Something seems to go wrong when node-gyp extracts the Node.js header tarball,
# on Windows specifically (this is most likely because node-tar treats
# the overwriting of existing files differently on Windows than on other OS --
# for good reasons, but still).
# The most likely cause of this issue is that node-gyp somehow extracts the
# same headers tarball twice, in parallel, in the same location, with race
# conditions in the tar extraction code leading to issues.
# The extraction result ends up in %LOCALAPPDATA%\node-gyp\Cache.
# Manually extracting the tarballs will solve this issue, so we're doing that
# here.
# For actually resolving the bug, we would probably need somebody with a local
# reproduction. However, it seems likely that other people will also encounter
# this issue, so there's also a good chance that this workaround will just
# not be needed with a future node-gyp version.

if [ x"$NODE_JS_VERSION" = x"" ]; then
if node -v; then
export NODE_JS_VERSION=$(node -p 'process.version.slice(1)')
else
echo "Need NODE_JS_VERSION to be set or Node.js to be installed for node-gyp bug workaround script"
exit 1
fi
fi

if [ x"$LOCALAPPDATA" = x"" ]; then
echo "No LOCALAPPDATA set, ignoring node-gyp bug workaround script"
exit
fi

set -x
CACHEDIR="$LOCALAPPDATA/node-gyp/Cache"
rm -rvf "$CACHEDIR"
mkdir -p "$CACHEDIR/$NODE_JS_VERSION"
cd "$CACHEDIR/$NODE_JS_VERSION"
curl -sSfLO "https://nodejs.org/download/release/v$NODE_JS_VERSION/node-v$NODE_JS_VERSION-headers.tar.gz"
tar --strip-components=1 -xvzf "node-v$NODE_JS_VERSION-headers.tar.gz"
for arch in x64 x86 arm64; do
mkdir $arch
pushd $arch
curl -sSfLO "https://nodejs.org/download/release/v$NODE_JS_VERSION/win-$arch/node.lib" || echo "no $arch v$NODE_JS_VERSION .lib file"
popd
done

# Finally, store the right installVersion value for current node-gyp versions
echo 9 > installVersion
5 changes: 4 additions & 1 deletion .evergreen/preinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ if [ -n "$IS_WINDOWS" ]; then
./node.exe node_modules/npm2/bin/npm-cli.js i -g npm@$NPM_VERSION
rm -rf node_modules/npm2/
chmod +x npm.cmd npm

cd ..
.evergreen/node-gyp-bug-workaround.sh
else
echo "Installing nodejs v${NODE_JS_VERSION} for ${PLATFORM}..."
curl -fs \
Expand All @@ -53,4 +56,4 @@ else

./bin/node lib/node_modules/npm2/bin/npm-cli.js i -g npm@$NPM_VERSION
rm -rf lib/node_modules/npm2/
fi
fi
5 changes: 4 additions & 1 deletion .github/workflows/authors-and-third-party-notices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ jobs:
- name: Install npm@8.3.1
run: |
npm install -g npm@8.3.1
npx --yes rimraf $LOCALAPPDATA/node-gyp/Cache || true

- name: Run node-gyp bug workaround script
run: |
bash .evergreen/node-gyp-bug-workaround.sh

- name: Install Dependencies
run: |
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ jobs:
- name: Install npm@8.3.1
run: |
npm install -g npm@8.3.1
npx --yes rimraf $LOCALAPPDATA/node-gyp/Cache || true

- name: Run node-gyp bug workaround script
run: |
bash .evergreen/node-gyp-bug-workaround.sh

- name: Install Dependencies
run: |
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/check-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ jobs:
- name: Install npm@8.3.1
run: |
npm install -g npm@8.3.1
npx --yes rimraf $LOCALAPPDATA/node-gyp/Cache || true

- name: Run node-gyp bug workaround script
run: |
bash .evergreen/node-gyp-bug-workaround.sh

- name: Install Dependencies
run: |
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/connectivity-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ jobs:
- name: Install npm@8.3.1
run: |
npm install -g npm@8.3.1
npx --yes rimraf $LOCALAPPDATA/node-gyp/Cache || true

- name: Run node-gyp bug workaround script
run: |
bash .evergreen/node-gyp-bug-workaround.sh

- name: Install Dependencies
run: |
Expand Down