Issue
I’ve broken my login flow into two separate Puppeteer → Run Custom Script nodes in n8n:
- Node A launches a browser, navigates, enters the username, and clicks “Continue.”
- Node B should pick up the same browser instance, enter the password, and submit.
But Node B always spins up a brand-new, blank browser page—losing the session and requiring a full re-login.
Goal
Have Node B attach to the exact same Puppeteer browser instance that Node A launched—so I can modularize steps (username, password, data extraction) while preserving session/cookies between nodes. Any advice on sharing the browser context or alternative patterns would be greatly appreciated!
instance information
Debug info
core
- n8nVersion: 1.92.2
- platform: docker (self-hosted)
- nodeJsVersion: 20.19.0
- database: sqlite
- executionMode: regular
- concurrency: -1
- license: enterprise (production)
- consumerId: a5ff568e-677f-4d43-bc6c-06834cf84be0
storage
- success: all
- error: all
- progress: false
- manual: true
- binaryMode: memory
pruning
- enabled: true
- maxAge: 336 hours
- maxCount: 10000 executions
client
- userAgent: mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/136.0.0.0 safari/537.36
- isTouchDevice: false
Generated at: 2025-05-13T13:04:52.048Z
Could you provide your workflows here?
- We recommend using Playwright over puppeteer, it is considered the new standard, much easier to use.
- It may be more effective to import the playwright/puppeteer node package and create scripts right in the code nodes. But unsure stability and how callbacks would work to determine completions.
- For your specific attempt, I would think you would need to pass the current user data dir. Although I am unsure if you can even “hook” puppeteer from another process, even if its still active from the initial process. That seems more complex than necessary.
Really how I would recommend it:
Since you are already on a server, just create a local webserver (node or python) that is a “handler” for browser based requests. You can then send a post/get request (with http node) to the defined endpoints to directly call sub functions of the browser automation.
Perhaps step 1 is localhost:8080/start_playwright, then localhost:8080/login (no need to separate the user and pass into their own, that seems unnecessarily redundant). Then there is localhost:8080/fill_form. You would pass the session id to login and fill form to maintain context of the original started browser that hasnt shutdown yet. then a /close_playwright. All endpoints just are wrappers in a single script.
You can pass the browser session into the webserver, and set defined user data dirs.