При помощи php exec я запускаю приложение на nodeJS, которое умеет делать скриншоты сайтов.
Само приложение это
capture-website-cli, под капотом которой
https://github.com/puppeteer/puppeteer.
Puppeteer is a Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol. Puppeteer runs headless by default, but can be configured to run full (non-headless) Chrome or Chromium.
Проблема в том, что если capture-website-cli не смог сделать скриншот сайта из-за того, что не получил ответ раньше таймаута, то мне в консоль вываливается сообщение об этом. И я не могу никак его перехватить
exec("capture-website https://yandex.com --output=img.jpg", $out);
TimeoutError: Navigation timeout of 15000 ms exceeded
at C:\Users\Vincent\AppData\Roaming\npm\node_modules\capture-website-cli\node_modules\puppeteer\lib\cjs\puppeteer\common\LifecycleWatcher.js:106:111
at async FrameManager.navigateFrame (C:\Users\Vincent\AppData\Roaming\npm\node_modules\capture-website-cli\node_modules\puppeteer\lib\cjs\puppeteer\common\FrameManager.js:90:21)
at async Frame.goto (C:\Users\Vincent\AppData\Roaming\npm\node_modules\capture-website-cli\node_modules\puppeteer\lib\cjs\puppeteer\common\FrameManager.js:417:16)
at async Page.goto (C:\Users\Vincent\AppData\Roaming\npm\node_modules\capture-website-cli\node_modules\puppeteer\lib\cjs\puppeteer\common\Page.js:825:16)
at async captureWebsite (C:\Users\Vincent\AppData\Roaming\npm\node_modules\capture-website-cli\node_modules\capture-website\index.js:232:2)
at async Object.module.exports.file (C:\Users\Vincent\AppData\Roaming\npm\node_modules\capture-website-cli\node_modules\capture-website\index.js:366:21)
at async C:\Users\Vincent\AppData\Roaming\npm\node_modules\capture-website-cli\cli.js:241:3
Как перехватить это сообщение, чтобы оно не выводилось в консоль? Даже ob_get_contents() не спасает. И более того, даже если я использую хитрую конструкцию типа той, что ниже, то все равно при том, что php скрипт закончил работу сообщение об ошибке все-равно прилетает в консоль.
pclose(popen("start /B " . "capture-website https://yandex.com --output=screen.jpg --timeout=10 > res.txt", "r"));