Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lookup: add jsdom #740

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/common-args.js
Expand Up @@ -73,8 +73,7 @@ module.exports = function commonArgs(app) {
.option('timeout', {
alias: 'o',
type: 'number',
description: 'Set timeout for npm install',
default: 1000 * 60 * 10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the default not be kept / how come the removal is necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the default is set at this point it overrides the module-specific timeout later on at https://github.com/nodejs/citgm/pull/740/files#diff-166959275b22802c268f62f152801cbcR9.

If --timeout is not provided, it falls back to kDefaultTimeout (which previously seems to have been redundant).

description: 'Set timeout for npm install'
})
.option('yarn', {
alias: 'y',
Expand Down
3 changes: 3 additions & 0 deletions lib/lookup.js
Expand Up @@ -162,6 +162,9 @@ function resolve(context) {
if (rep.yarn) {
context.module.useYarn = true;
}
if (rep.timeoutLength) {
context.module.timeoutLength = rep.timeoutLength;
}
context.module.flaky = context.options.failFlaky
? false
: isMatch(rep.flaky);
Expand Down
6 changes: 6 additions & 0 deletions lib/lookup.json
Expand Up @@ -237,6 +237,12 @@
"maintainers": "jeresig",
"ignoreGitHead": true
},
"jsdom": {
"maintainers": ["domenic", "Zirro"],
"timeoutLength": 1200000,
"useGitClone": true,
"yarn": true
},
"koa": {
"flaky": "ubuntu",
"maintainers": "tj"
Expand Down
8 changes: 7 additions & 1 deletion lib/package-manager/test.js
Expand Up @@ -106,7 +106,13 @@ async function test(packageManager, context) {
);

const proc = spawn(bin, args, options);
const finish = timeout(context, proc, runScript, 'Test');
const finish = timeout(
context,
proc,
runScript,
'Test',
context.module.timeoutLength
);

proc.stdout.on('data', (data) => {
context.testOutput.append(data);
Expand Down
5 changes: 3 additions & 2 deletions lib/timeout.js
Expand Up @@ -3,9 +3,10 @@
// Default timeout to 10 minutes if not provided
const kDefaultTimeout = 1000 * 60 * 10;

function timeout(context, proc, next, step) {
function timeout(context, proc, next, step, moduleConfigTimeout) {
let hasRun = false;
const delay = context.options.timeoutLength || kDefaultTimeout;
const delay =
context.options.timeoutLength || moduleConfigTimeout || kDefaultTimeout;
// Third arg === `true` is the way to signal `finish` that this is a timeout.
// Otherwise it acts like a "regular" callback, i.e. `(err, ret) => {}`.
// `if (timedOut)` will overwrite `err` & `ret`, so first 2 args are ignored.
Expand Down