Skip to content

Commit 3756be8

Browse files
joyeecheungBethGriggs
authored andcommittedApr 6, 2020
tools: add NODE_TEST_NO_INTERNET to the doc builder
At the moment the doc builder tries to access the internet for CHANGELOG information and only falls back to local sources after the connection fails or a 5 second timeout. This means that the doc building could take at least 7 minutes on a machine with hijacked connection to Github for useless network attempts. This patch adds a NODE_TEST_NO_INTERNET environment variable to directly bypass these attempts so that docs can be built in reasonable time on a machine like that. Backport-PR-URL: #32642 PR-URL: #31849 Fixes: #29918 Reviewed-By: Matheus Marchini <mat@mmarchini.me> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent ac1ea73 commit 3756be8

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed
 

‎tools/doc/versions.js

+16-10
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ const getUrl = (url) => {
3131
});
3232
};
3333

34+
const kNoInternet = !!process.env.NODE_TEST_NO_INTERNET;
35+
3436
module.exports = {
3537
async versions() {
3638
if (_versions) {
@@ -42,16 +44,20 @@ module.exports = {
4244
const url =
4345
'https://raw.githubusercontent.com/nodejs/node/master/CHANGELOG.md';
4446
let changelog;
45-
try {
46-
changelog = await getUrl(url);
47-
} catch (e) {
48-
// Fail if this is a release build, otherwise fallback to local files.
49-
if (isRelease()) {
50-
throw e;
51-
} else {
52-
const file = path.join(srcRoot, 'CHANGELOG.md');
53-
console.warn(`Unable to retrieve ${url}. Falling back to ${file}.`);
54-
changelog = readFileSync(file, { encoding: 'utf8' });
47+
const file = path.join(srcRoot, 'CHANGELOG.md');
48+
if (kNoInternet) {
49+
changelog = readFileSync(file, { encoding: 'utf8' });
50+
} else {
51+
try {
52+
changelog = await getUrl(url);
53+
} catch (e) {
54+
// Fail if this is a release build, otherwise fallback to local files.
55+
if (isRelease()) {
56+
throw e;
57+
} else {
58+
console.warn(`Unable to retrieve ${url}. Falling back to ${file}.`);
59+
changelog = readFileSync(file, { encoding: 'utf8' });
60+
}
5561
}
5662
}
5763
const ltsRE = /Long Term Support/i;

0 commit comments

Comments
 (0)
Please sign in to comment.