Skip to content

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

@mxschmitt

Description

@mxschmitt

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.

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