Skip to content

[BUG] playwright-electron fails to close down after a screenshot is taken #4571

@cserby

Description

@cserby

Context:

  • Playwright Version: playwright-electron "0.5.0"
  • Operating System: Linux
  • Node.js version: v10.16.0
  • Browser: Electron
  • Extra: used with cucumber-js 7.0

Code Snippet

I have an After hook:

After(function () {
    const world: World = (this as World);
    return world.stopApp();
});

where world.stopApp() is a Promise<void>, and this works as expected: after everything is done, app gets closed, node exits.

Now, if I change it to:

After(function (testCase) {
  const world: World = this as World;
  return Promise.resolve()
    .then(() => {
      if (testCase.result && testCase.result.status !== Status.PASSED) {
        return world.getMainWindow().then(
          window =>
            window!
              .screenshot({
                type: 'png',
                fullPage: true,
              })
              .then(screenshot => world.attach(screenshot, 'image/png'))
        );
      } else { return Promise.resolve(); }
    })
    .then(() => world.stopApp());
});

, then the screenshot gets taken, the app gets closed, but nevertheless, the node process stays hanging when done, and then after a certain time it exits with:

0m03.194s (executing steps: 0m03.184s)
/home/cserby/src/node_modules/playwright-electron/lib/client/connection.js:138
            throw new Error(`Cannot find parent object ${parentGuid} to create ${guid}`);
            ^
Error: Cannot find parent object ElectronApplication@063e69bc2fb5f6904e9734e426ad2eb7 to create JSHandle@37d05e59586959bd4828bc50e5d5edff
    at Connection._createRemoteObject (/home/cserby/src/node_modules/playwright-electron/lib/client/connection.js:138:19)
    at Connection.dispatch (/home/cserby/src/node_modules/playwright-electron/lib/client/connection.js:105:18)
    at Immediate.setImmediate (/home/cserby/src/node_modules/playwright-electron/lib/inprocess.js:42:85)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)

It's like in this case, playwright would fail to close down correctly.

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