puppeteer : console.log 评估触发错误 "Unhandled promise rejection"

puppeteer : console.log in evaluate triggers error "Unhandled promise rejection"

In puppeteer , when i want to use console.log from evaluate , it triggers me an error

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({headless: false});

  const page = await browser.newPage();
  page.on('console', msg => console.log('PAGE LOG:', ...msg.args));
  await page.goto('http://google.com',  {waitUntil: 'load'});
  await page.evaluate(async() => console.log('url is ${location.href}'));
  browser.close();
})();  

(node:70544) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: undefined is not iterable (node:70544) [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.

你知道怎么处理吗?

msg.args 值未定义,因此当您尝试使用扩展运算符 (...msg.args) 时,它失败了。

要么记录 msg.args,要么用 null / undefined 检查包装它