question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Double ^c not close all browser instances

See original GitHub issue

Steps to reproduce

  • Puppeteer version: 1.1.1
  • Platform / OS version: windows
  • Node.js version: 8.9.4

What steps will reproduce the problem? I use this code :

const puppeteer = require('puppeteer');
var express = require('express');
var app = express();

var browser1 = { browser:{}, page:{}, isFree:true, number:1};
var browser2 = { browser:{}, page:{}, isFree:true, number:2};
var browser3 = { browser:{}, page:{}, isFree:true, number:3};
var browser4 = { browser:{}, page:{}, isFree:true, number:4};
var browser5 = { browser:{}, page:{}, isFree:true, number:5};

app.get('/', async (req, res) => {
  let pdf = await createPDF(req, res);
  if (!pdf){
    res.status(503).send();
  }
  res.status(200).send();
});
app.listen(3000);


let createPDF = async (request, response) => {
  let freeBrowser = await getFreeBrowser(response);
  if (freeBrowser) {
    freeBrowser.isFree = false;
    freeBrowser.browser = await puppeteer.launch({headless: false});
    freeBrowser.page = await freeBrowser.browser.newPage();
}else{
  return false;
}
    let url = request.query.url;
    let JSESSIONID = request.query.JSESSIONID;
    await freeBrowser.page.setCookie({ name: "JSESSIONID", value: JSESSIONID, url: url });
    await freeBrowser.page.goto(url,{waitUntil:'domcontentloaded'});
    await freeBrowser.page.waitForSelector("#ngb-tab-0-panel > grid > div:nth-child(3) > column > make-text > div > span",{'visible':true});
    
    console.log(freeBrowser.number);

    return true;
  }

let getFreeBrowser = (response) => {
  let browser;

  if (browser1.isFree) {
    browser = browser1;
  }
  else if (browser2.isFree) {
    browser = browser2;
  }
  else if (browser3.isFree) {
    browser = browser3;
  }
  else if (browser4.isFree) {
    browser = browser4;
  }
  else if (browser5.isFree) {
    browser = browser5;
  }
  if (browser) {
    return (browser);
  } else {
    return false;
  }
}

What is the expected result? When I shutdown the node server when all browser opend by double ^c not all browser instances closed. Note: When use one ^c all browser instances closed.

What happens instead? All browser instances should closed just like one ^c.

I have a question too, what should happen if the node server closed suddenly ? The browsers now will still opened!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
aslushnikovcommented, Mar 15, 2018

#2081 is merged so this should be fixed now on tip-of-tree. We’ll publish a new version on npm today.

1reaction
JoelEinbindercommented, Mar 15, 2018

I can repro this. It looks like it will be fixed by https://github.com/GoogleChrome/puppeteer/pull/2081

Read more comments on GitHub >

github_iconTop Results From Across the Web

Double ^c not close all browser instances · Issue #2191 - GitHub
When I shutdown the node server when all browser opend by double ^c not all browser instances closed. Note: When use one ^c...
Read more >
How to close all the browser instances before a test execution ...
I am trying to close the already launched chrome browser windows by the below code, but this is not helping in closing the...
Read more >
Close all Chrome browser or Firefox browser instances at once
This way all instances of a process/browser can be killed at once by running the above command on command prompt.
Read more >
47134 - Command-W Sometimes (random occurrence) closes ...
Firefox 3.x: IE 7: IE 8: What steps will reproduce the problem? Problem is random. Doesn't happen every time. 1. Press command-w to...
Read more >
Windows Speech Recognition commands - Microsoft Support
Learn how to control your PC by voice using Windows Speech Recognition commands for dictation, keyboard shortcuts, punctuation, apps, and more.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found