fawazahmed0 / youtube-uploader

Free youtube video uploader with no limits
MIT License
358 stars 84 forks source link

Chromium not render and the error: Session closed. Most likely the page has been closed. #208

Open ngoanpv opened 1 year ago

ngoanpv commented 1 year ago

Hello, I don't see the chromium open when I start the code. The error is shown as below:

/Users/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:218
            return Promise.reject(new Error(`Protocol error (${method}): Session closed. Most likely the ${this._targetType} has been closed.));
                                  ^

Error: Protocol error (Page.navigate): Session closed. Most likely the page has been closed.
    at CDPSession.send (/Users/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:218:35)
    at next (/Users/node_modules/puppeteer-extra-plugin-stealth/evasions/sourceurl/index.js:34:41)
    at CDPSession.send (/Users/node_modules/puppeteer-extra-plugin-stealth/evasions/sourceurl/index.js:67:18)
    at navigate (/Users/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:158:47)
    at FrameManager.navigateFrame (/Users/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:142:13)
    at Frame.goto (/Users/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:541:41)
    at Page.goto (/Users/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:1200:53)
    at login (/Users/node_modules/youtube-videos-uploader/dist/upload.js:849:21)
    at loadAccount (/Users/node_modules/youtube-videos-uploader/dist/upload.js:744:19)
    at async upload (/Users//node_modules/youtube-videos-uploader/dist/upload.js:42:9)
gaxwtycalh890 commented 1 year ago

Same issue here, anyone has a solution?

eumkz commented 6 months ago

I faced this after upgrading to macOS Sonoma (coming from macOS Monterey).

This patch helped me, and it might help you:

diff --git a/dist/upload.js b/dist/upload.js
index 164cda3eb777633922d43bdf988d3d827dda3287..b7c0b7187749bdeb4ab0d3dbfeb79c6a284fad2c 100644
--- a/dist/upload.js
+++ b/dist/upload.js
@@ -11,6 +11,7 @@ const path_1 = __importDefault(require("path"));
 const StealthPlugin = require('puppeteer-extra-plugin-stealth')();
 StealthPlugin.enabledEvasions.delete('iframe.contentWindow');
 StealthPlugin.enabledEvasions.delete('navigator.plugins');
+StealthPlugin.enabledEvasions.delete('media.codecs');
 puppeteer_extra_1.default.use(StealthPlugin);
 const maxTitleLen = 100;
 const maxDescLen = 5000;

You might need to set the executablePath to a different installation, too.

I ran pnpm dlx @puppeteer/browsers install chrome@stable in my home directory, then did this when calling upload:

const [link] = await upload(auth, [videoOptions], {
  executablePath: process.env.HOME +
      '/chrome/mac-124.0.6367.91/chrome-mac-x64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing',
})

Your path may differ. Read the logs of the pnpm dlx @puppeteer/browsers install chrome@stable command.