fix: a human-readable error when lock cannot be acquired (#8768)

Fixes #8709
This commit is contained in:
Andrey Lushnikov 2021-09-08 16:03:16 +03:00 committed by GitHub
parent 25b5927a4d
commit 32ea4f542b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -562,6 +562,25 @@ export class Registry {
else
throw new Error(`ERROR: Playwright does not support installing ${executable.name}`);
}
} catch (e) {
if (e.code === 'ELOCKED') {
const rmCommand = process.platform === 'win32' ? 'rm -R' : 'rm -rf';
throw new Error('\n' + wrapInASCIIBox([
`An active lockfile is found at:`,
``,
` ${lockfilePath}`,
``,
`Either:`,
`- wait a few minutes if other Playwright is installing browsers in parallel`,
`- remove lock manually with:`,
``,
` ${rmCommand} ${lockfilePath}`,
``,
`<3 Playwright Team`,
].join('\n'), 1));
} else {
throw e;
}
} finally {
await releaseLock();
}