title: UnhandledPromiseRejectionWarning: Error: Protocol error (Runtime.callFunctionOn): Target closed. (Puppeteer)
body: <p>I am new to Puppeteer and Node and I get this error when trying to execute the following code:</p>
  
  <pre><code>'use strict';
  
  const puppeteer = require('puppeteer');
  const evalLib = require('./oaa_a11y_evaluation.js');
  
  function evaluateRules() {
    var ruleset = OpenAjax.a11y.RulesetManager.getRuleset("ARIA_STRICT");
    var evaluator_factory = OpenAjax.a11y.EvaluatorFactory.newInstance();
    evaluator_factory.setParameter('ruleset', ruleset);
    evaluator_factory.setFeature('eventProcessing', 'fae-util');
    evaluator_factory.setFeature('groups', 7);
    var evaluator = evaluator_factory.newEvaluator();
    var evaluation = evaluator.evaluate(window.document, document.title, document.location.href);
    // var out = evaluation.toJSON(true);
    return;
  }
  
  (async() =&gt; {
    const browser = await puppeteer.launch();
    var page = await browser.newPage();
    await page.goto('http://mihirkumar.com/', {waitUntil: 'load'});
    page.evaluate(evaluateRules);
    await browser.close();
  })();
  </code></pre>
  
  <p>Here's the error message in full detail:</p>
  
  <pre><code>(node:27876) UnhandledPromiseRejectionWarning: Error: Protocol error (Runtime.callFunctionOn): Target closed.
  at Promise (C:\Users\Mihir\fae\node_modules\puppeteer\lib\Connection.js:200:56)
  at new Promise (&lt;anonymous&gt;)
  at CDPSession.send (C:\Users\Mihir\fae\node_modules\puppeteer\lib\Connection.js:199:12)
  at ExecutionContext.evaluateHandle (C:\Users\Mihir\fae\node_modules\puppeteer\lib\ExecutionContext.js:79:75)
  at ExecutionContext.evaluate (C:\Users\Mihir\fae\node_modules\puppeteer\lib\ExecutionContext.js:46:31)
  at Frame.evaluate (C:\Users\Mihir\fae\node_modules\puppeteer\lib\FrameManager.js:326:20)
  at &lt;anonymous&gt;
  at process._tickCallback (internal/process/next_tick.js:188:7)
  (node:27876) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
  (node:27876) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  </code></pre>
  
  <p>Other examples from <a href="https://github.com/GoogleChromeLabs/puppeteer-examples" rel="noreferrer">https://github.com/GoogleChromeLabs/puppeteer-examples</a> run perfectly fine so I don't believe I need to use the fixes mentioned <a href="https://stackoverflow.com/questions/47266005/unhandled-promise-rejection-rejection-id-1-error-kill-esrch">here</a>. Thanks for the help.</p>