Skip to content

fix: browser profile leak#50

Merged
szmarczak merged 5 commits into
masterfrom
profile-leak
Sep 30, 2021
Merged

fix: browser profile leak#50
szmarczak merged 5 commits into
masterfrom
profile-leak

Conversation

@szmarczak
Copy link
Copy Markdown
Contributor

Fixes #32

Tested manually via:

const { BrowserPool, PlaywrightPlugin, PuppeteerPlugin } = require('.');
// const playwright = require('playwright');

const browserPool = new BrowserPool({
    browserPlugins: [new PlaywrightPlugin(require('playwright').chromium)],
});

console.time('x');

// An asynchronous IIFE (immediately invoked function expression)
// allows us to use the 'await' keyword.
(async () => {
    console.timeLog('x', 'before new page');
    // // Launches Chromium with Playwright and returns a Playwright Page.
    const page1 = await browserPool.newPage();
    console.timeLog('x', 'after new page');
    // // You can interact with the page as you're used to.
    // await page1.goto('https://example.com');
    // // When you're done, close the page.
    await page1.close();
    console.timeLog('x', 'after page close');
    // // Opens a second page in the same browser.
    // const page2 = await browserPool.newPage();
    // When everything's finished, tear down the pool.
    await browserPool.destroy();
    console.timeLog('x', 'after pool destroy');

    console.log(process._getActiveHandles().length);
    process.exit();
})();

Copy link
Copy Markdown
Member

@mnmkng mnmkng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm besides that one comment.

const context = plugin.createLaunchContext();
browser = await plugin.launch(context as never);

expect(fs.existsSync(context.userDataDir)).toBeTruthy();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we remove this line, shouldn't we remove the whole test?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, thanks

@szmarczak szmarczak merged commit 3003fb2 into master Sep 30, 2021
@szmarczak szmarczak deleted the profile-leak branch September 30, 2021 10:04
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 this pull request may close these issues.

Generated userDataDir are not removed from the disk

2 participants