Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

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

Andrey Lushnikov32ea4f542b8e
diff --git a/src/utils/registry.ts b/src/utils/registry.ts
index 5a32fd353f..e26074e7d2 100644
--- a/src/utils/registry.ts
+++ b/src/utils/registry.ts
@@ -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();
}