Skip to content

[BUG] Installation of playwright is successful even if fetching browser binaries fails #1731

@lukaszfiszer

Description

@lukaszfiszer

Context:

  • Playwright Version: 0.12.1
  • Operating System: Windows
  • Extra: node 12.16

Describe the bug

If fetching browser binaries fails during installation of playwright (for example because of network error) the whole installation is still successful. When using npm a warning is printed to the console. In yarn, which swallows console logs from postinstall scripts, there is no indication that something went wrong.

The root cause of the bug is that promise rejection in https://github.com/microsoft/playwright/blob/master/src/server/browserFetcher.ts#L147 is not handled in any way, for example with process.exit(1). Because in node<=12 unhandled promise rejections does not terminate the process, this causes whole installation script to succeed instead of failing it.

Code Snippet

npm

λ npm install playwright

> [email protected] install C:\Users\hlukafis\projects\test\node_modules\playwright
> node install.js

(node:16680) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 216.58.205.48:443
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1137:16)
(node:16680) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:16680) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

+ [email protected]
added 46 packages from 36 contributors in 17.19s

2 packages are looking for funding
  run `npm fund` for details

yarn

λ yarn add playwright
yarn add v1.21.1
info No lockfile found.
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 40 new dependencies.
info Direct dependencies
└─ [email protected]
info All dependencies
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
Done in 17.66s.

C:\Users\hlukafis\projects\test  ([email protected])
λ ls node_modules\playwright
index.d.ts  index.js  install.js  package.json  README.md // binaries here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions