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

[BUG] TypeError: domain.enter is not a function/ Browser.close() Promise does not resolve when "domain" package is used #3848

Closed
mxschmitt opened this issue Sep 11, 2020 · 4 comments · Fixed by #3851

Comments

@mxschmitt
Copy link
Member

mxschmitt commented Sep 11, 2020

Context:

  • Playwright Version: 1.4
  • Operating System: Mac
  • Node.js version: 12 / 13
  • Browser: All
  • Extra: Originally from Try Playwright

Code Snippet

const domain = require("domain")
const playwright = require("playwright");

(async () => {
  const local = domain.create();
  local.run(() => { })
  const browser = await playwright.chromium.launch();
  const context = await browser.newContext();
  await context.newPage();
  console.log("before-block")
  await browser.close();
  console.log("after-block")
})();

With express Sentry plugin:

const express = require('express')
const Sentry = require('@sentry/node')
const playwright = require("playwright");

const app = express()

// after removing it will work again
app.use(Sentry.Handlers.requestHandler())

app.get("/", async (req, resp) => {
  try {
    const browser = await playwright.chromium.launch();
    const context = await browser.newContext();
    await context.newPage();
    console.log("before-block")
    await browser.close();
    console.log("after-block")
  } catch (error) {
    console.log(error)
  }
})

app.listen(3001, () => {
  console.log("curl -v http://localhost:3001")
})

Their "domain" implementation: https://github.com/getsentry/sentry-javascript/blob/7c142839036e77161a6f707196762eb718b723cc/packages/node/src/handlers.ts#L272-L281

On Heroku:

image

Describe the bug

Browser.close() blocks. The "after block" message won't get logged. This has probably something to do with this Slack message.

Maybe upstream? nodejs/node#34720
Relates getsentry/sentry-javascript#1843

But not sure why it did not happen in 1.3.

@mxschmitt mxschmitt changed the title [BUG] Browser.close() does not resolve when "domain" package is used [BUG] Browser.close() Promise does not resolve when "domain" package is used Sep 11, 2020
@mxschmitt mxschmitt changed the title [BUG] Browser.close() Promise does not resolve when "domain" package is used [BUG] TypeError: domain.enter is not a function/ Browser.close() Promise does not resolve when "domain" package is used Sep 11, 2020
@vrknetha
Copy link

I am getting the same error once i upgrade to 1.4. I do not use the domain package anywhere but still getting the error

Playwright: 1.4
OS: Windows and Ubuntu 18.04

image

@sergeyt
Copy link

sergeyt commented Sep 16, 2020

getting this error if using ts-node to run a test script

@mxschmitt
Copy link
Member Author

mxschmitt commented Sep 16, 2020

getting this error if using ts-node to run a test script

Yep we didn't release a version yet with this fix. As a workaround you can use the bleeding edge (master) version: npm install playwright@next until we released 1.4.1.

@sergeyt
Copy link

sergeyt commented Sep 16, 2020

Another workaround. Compile TS into JS and run compiled code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants