I'm building a script with puppeteer to do a Youtube login. I wanted my login session saved with userDataDir when I open firefox with puppeteer. However, adding the userDataDir argument is crashing my browser launch.
const browser = await puppeteer.launch({
product: 'firefox',
args: [
'-wait-for-browser',
"--no-sandbox"
],
headless: true,
userDataDir: "./user_data",
dumpio: true
});
The error I'm getting is this:
Users/calvinchen/node_modules/puppeteer/lib/cjs/common/Connection.js:54
this._callbacks.set(id, { resolve, reject, error: new Error(), method });
^
Error: Protocol error (Target.setDiscoverTargets): can't access property "currentWindowGlobal", this.browsingContext is null get title@chrome://remote/content/targets/TabTarget.jsm:111:5
_getTargetInfo@chrome://remote/content/domains/parent/Target.jsm:181:7
_onTargetCreated@chrome://remote/content/domains/parent/Target.jsm:190:29
setDiscoverTargets@chrome://remote/content/domains/parent/Target.jsm:91:12
execute@chrome://remote/content/domains/DomainCache.jsm:99:25
execute@chrome://remote/content/sessions/Session.jsm:64:25
onPacket@chrome://remote/content/Connection.jsm:225:36
onMessage@chrome://remote/content/server/WebSocketTransport.jsm:85:18
handleEvent@chrome://remote/content/server/WebSocketTransport.jsm:67:14
at /Users/calvinchen/node_modules/puppeteer/lib/cjs/common/Connection.js:54:63
at new Promise (<anonymous>)
at Connection.send (/Users/calvinchen/node_modules/puppeteer/lib/cjs/common/Connection.js:53:16)
at Function.create (/Users/calvinchen/node_modules/puppeteer/lib/cjs/common/Browser.js:90:26)
at FirefoxLauncher.launch (/Users/calvinchen/node_modules/puppeteer/lib/cjs/node/Launcher.js:238:53)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at async /Users/calvinchen/Desktop/YoutubeUploaderV2/youtubeuploader.js:32:21
When I commented out the userdatadir and the browser launches as intended.