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

resource release not getting called #280

Open
aksharj opened this issue May 20, 2020 · 2 comments
Open

resource release not getting called #280

aksharj opened this issue May 20, 2020 · 2 comments

Comments

@aksharj
Copy link

aksharj commented May 20, 2020

Hi,

*** Just an update here, i need to explictly call destroy function to release the resourcse***, may be i have configured something incorrectly

Sorry to be posting it here but i am unable to find an answer anywhere else.

I am trying to create a pupeteer pool and the destroy method from the factory is not getting called.

I am able to acquire resource but not able to release and destroy is not called.

here are relevant parts of the code

browser-pool.js

const genericPool = require('generic-pool');
const puppeteer = require('puppeteer');

module.exports = function() {

  const browserParams = process.env.NODE_ENV == 'development' ? {
    headless: false,
    devtools: false,
    executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
  }
  :
  {
    headless: true,
    devtools: false,
    executablePath: 'google-chrome-unstable',
    args: ['--no-sandbox', '--disable-dev-shm-usage']
  };

  const factory = {
    create: function() {
      return puppeteer.launch(browserParams);
    },
    destroy: function(instance) {
      console.log('closing browser');
      instance.close();
    },
    validate: (browserInstance) => {
      console.log(`maxUses is ${maxUses}`);
      return validator(browserInstance)
        .then(valid => Promise.resolve(valid && (maxUses <= 0 || browserInstance.useCount < maxUses)))
    },
  }

  const opts = {
    max: 2
  };

  return genericPool.createPool(factory, opts);
};

processor.js

const pool = require('./browser-pool');


async function performExport(params){
  let client = "";
  const poolInstance = pool();
  const resp = workAround.acquire().then(async function(c){
// do processing
poolInstance.release(c); //***Does not call destroy**
});

I am missing something but not sure what. Any help would be really great. Thanks

@rkrier85233
Copy link

I'm seeing the same thing. I have my max: 10 and min: 0 and after I release all resources I still have available: 1.

@Abdillah
Copy link

Yes, I'm observing the same.

Additionally, calling drain and clear doesn't call destroy. Why is that?

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

No branches or pull requests

3 participants