You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
macOS: every session leaks a ~1.4 GB Chrome code_sign_clone because Chrome is SIGKILLed on shutdown #3154
Environment: chrome-devtools-mcp 1.10.1, Google Chrome 155.0.8059.40 (stable), macOS 27.0, Apple Silicon. Client: Codex CLI 0.162.1.
What happens
Since Chrome ~121, Chrome copies its app bundle into $(getconf DARWIN_USER_DIR)/../X/com.google.Chrome.code_sign_clone/code_sign_clone.XXXXXX at launch, and deletes the copy only on a graceful shutdown. When an MCP client ends a session by signalling the server, Chrome is killed before it can clean up, so the copy stays. I had 53 leftover copies, reported as 74 GB (they share APFS blocks, but each new Chrome version costs another ~1.4 GB).
Cause
The bundled @puppeteer/browsers handles SIGTERM/SIGHUP with close() → kill(), which sends process.kill(-pid, 'SIGKILL') to Chrome's whole process group (packages/browsers/src/launch.ts, still present in v3.2.5). SIGINT calls kill() directly. None of these paths sends Browser.close over CDP first.
Repro
Count code_sign_clone.* dirs before and after each session:
How the session ended
Leaked
MCP sent SIGTERM
3/3
MCP sent SIGINT
1/1
MCP sent SIGKILL
1/2
Real codex exec session using new_page
2/2
stdin closed (server calls browser.close())
0/2
Same Codex session with --executablePath → Chrome for Testing
0/2
Chrome itself also leaks the copy on a plain SIGTERM or SIGKILL sent directly to it, so only a CDP Browser.close avoids the leak.
Suggested fix
On SIGTERM/SIGINT/SIGHUP, try browser.close() (CDP) with a short timeout before falling back to the process-group SIGKILL. Alternatively, document --executablePath pointing at Chrome for Testing as the workaround on macOS, since Chrome for Testing doesn't create these copies.
Workaround
--executablePath=<path to Google Chrome for Testing>
On SIGTERM/SIGINT/SIGHUP, try browser.close() (CDP) with a short timeout before falling back to the process-group SIGKILL. Alternatively, document --executablePath pointing at Chrome for Testing as the workaround on macOS, since Chrome for Testing doesn't create these copies.
this is how the browser is closed in the latest version which sounds like the suggested fix:
Thanks! I re-tested on 1.11.0 with a scripted repro. The graceful browser.close() path is there, but it loses a race: BrowserManager calls puppeteer.launch() without handleSIGINT/handleSIGTERM/handleSIGHUP: false, so Puppeteer's own signal handler also fires on the same signal and synchronously runs process.kill(-pid, 'SIGKILL') on Chrome's process group before shutdown() → browser.close() completes. Chrome only deletes its code_sign_clone on a graceful close, so it leaks.
Results (stable Chrome 155, macOS 27, Apple Silicon):
Signal
1.11.0
1.11.0 + handleSIGINT/SIGTERM/SIGHUP: false in puppeteer.launch()
SIGTERM
leaked (2/2)
clean (2/2)
SIGINT
leaked
clean
SIGHUP
leaked
clean
stdin close
clean
—
Suggested fix: pass handleSIGINT: false, handleSIGTERM: false, handleSIGHUP: false to puppeteer.launch() in BrowserManager.js, since chrome-devtools-mcp-main.js already handles those signals itself.
Repro: npm i chrome-devtools-mcp@latest && node repro.mjs SIGTERM (prints LEAKED or clean; exit code 1 on leak).
repro.mjs
// Repro for ChromeDevTools/chrome-devtools-mcp#3154 (macOS only).// Launches the MCP server over stdio, makes it start Chrome, sends a signal,// then counts Chrome code_sign_clone directories left behind.//// npm i chrome-devtools-mcp@latest// node repro.mjs [SIGTERM|SIGINT|SIGHUP|stdin] (default SIGTERM)// MCP_BIN=/path/to/build/src/bin/chrome-devtools-mcp.js node repro.mjs//// Uses stable Chrome (the default channel); Chrome for Testing makes no clone.import{spawn,execFileSync}from'node:child_process';import{readdirSync,existsSync}from'node:fs';import{dirname,join}from'node:path';import{setTimeoutassleep}from'node:timers/promises';import{createInterface}from'node:readline';import{createRequire}from'node:module';constmode=process.argv[2]??'SIGTERM';consttempDir=execFileSync('getconf',['DARWIN_USER_TEMP_DIR']).toString().trim();constcloneDir=join(dirname(tempDir),'X','com.google.Chrome.code_sign_clone');constclones=()=>existsSync(cloneDir) ? readdirSync(cloneDir).filter(d=>d.startsWith('code_sign_clone.')).length : 0;// Run node directly (not via npx) so the signal reaches the server process itself.constbin=process.env.MCP_BIN??createRequire(import.meta.url).resolve('chrome-devtools-mcp/package.json').replace(/package\.json$/,'build/src/bin/chrome-devtools-mcp.js');constbefore=clones();constserver=spawn('node',[bin,'--isolated','--no-usage-statistics'],{stdio: ['pipe','pipe','inherit']});constlines=createInterface({input: server.stdout});constpending=newMap();lines.on('line',l=>{constmsg=JSON.parse(l);pending.get(msg.id)?.(msg);});letnextId=1;constrpc=(method,params)=>newPromise(resolve=>{constid=nextId++;pending.set(id,resolve);server.stdin.write(JSON.stringify({jsonrpc: '2.0', id, method, params})+'\n');});awaitrpc('initialize',{protocolVersion: '2025-06-18',capabilities: {},clientInfo: {name: 'repro',version: '0'}});server.stdin.write(JSON.stringify({jsonrpc: '2.0',method: 'notifications/initialized'})+'\n');awaitrpc('tools/call',{name: 'list_pages',arguments: {}});constduring=clones();constexited=newPromise(resolve=>server.on('exit',resolve));if(mode==='stdin')server.stdin.end();elseserver.kill(mode);awaitexited;awaitsleep(8000);// give Chrome time to delete its clone on a graceful exitconstafter=clones();console.log(`${mode}: before=${before} during=${during} after=${after} -> ${after>before ? 'LEAKED' : 'clean'}`);process.exit(after>before ? 1 : 0);
❯ node repro.mjs
chrome-devtools-mcp exposes content of the browser instance to the MCP clients allowing them to inspect,
debug, and modify any data in the browser or DevTools.
Avoid sharing sensitive or personal information that you do not want to share with MCP clients.
Performance tools may send trace URLs to the Google CrUX API to fetch real-user experience data. To disable, run with --no-performance-crux.
SIGTERM: before=1 during=1 after=1 -> clean
~/src/chrome-devtools-mcp main 13s
❯ node repro.mjs
chrome-devtools-mcp exposes content of the browser instance to the MCP clients allowing them to inspect,
debug, and modify any data in the browser or DevTools.
Avoid sharing sensitive or personal information that you do not want to share with MCP clients.
Performance tools may send trace URLs to the Google CrUX API to fetch real-user experience data. To disable, run with --no-performance-crux.
SIGTERM: before=1 during=1 after=1 -> clean
~/src/chrome-devtools-mcp main 8s
❯ node repro.mjs
chrome-devtools-mcp exposes content of the browser instance to the MCP clients allowing them to inspect,
debug, and modify any data in the browser or DevTools.
Avoid sharing sensitive or personal information that you do not want to share with MCP clients.
Performance tools may send trace URLs to the Google CrUX API to fetch real-user experience data. To disable, run with --no-performance-crux.
SIGTERM: before=1 during=1 after=1 -> clean
As far as I know Puppeteer also first tries graceful close before killing the hanging browser.
Thanks for running it! In your output during equals before (1 → 1), so Chrome never created a code-sign clone, which means that run can't show the leak. Per Chromium's code_sign_clone_manager.mm, kMacAppCodeSignClone is enabled by default but compiled out for Chrome for Testing, and the clone is only removed from ~CodeSignCloneManager during a graceful shutdown. A SIGKILL skips it, and /var/folders/…/X is only wiped at reboot, so leaks pile up over uptime (53 after 12 days here). Could you check whether the launched Chrome is Chrome for Testing or a non-stable build? The updated repro below prints the executable path and reports INCONCLUSIVE when no clone is created.
On my machine (stable Chrome 155.0.8059.84 from /Applications, macOS 27.0.1): before=6 during=7 after=7 → LEAKED. For SIGTERM/SIGHUP, @puppeteer/browsers calls close(), which goes straight to kill() and sends process.kill(-pid, 'SIGKILL') (launch.ts L436–450, L492). There's no CDP Browser.close on that path. Passing handleSIGTERM/SIGINT/SIGHUP: false to puppeteer.launch() lets the MCP's own shutdown() → browser.close() run, and then the clone is cleaned up (4/4 here).
repro.mjs (updated)
// Repro for ChromeDevTools/chrome-devtools-mcp#3154 (macOS only).// Launches the MCP server over stdio, makes it start Chrome, sends a signal,// then counts Chrome code_sign_clone directories left behind.//// npm i chrome-devtools-mcp@latest// node repro.mjs [SIGTERM|SIGINT|SIGHUP|stdin] (default SIGTERM)// MCP_BIN=/path/to/build/src/bin/chrome-devtools-mcp.js node repro.mjs//// Uses stable Chrome (the default channel); Chrome for Testing makes no clone.import{spawn,execFileSync}from'node:child_process';import{readdirSync,existsSync}from'node:fs';import{dirname,join}from'node:path';import{setTimeoutassleep}from'node:timers/promises';import{createInterface}from'node:readline';import{createRequire}from'node:module';constmode=process.argv[2]??'SIGTERM';consttempDir=execFileSync('getconf',['DARWIN_USER_TEMP_DIR']).toString().trim();constcloneDir=join(dirname(tempDir),'X','com.google.Chrome.code_sign_clone');constclones=()=>existsSync(cloneDir) ? readdirSync(cloneDir).filter(d=>d.startsWith('code_sign_clone.')).length : 0;// Run node directly (not via npx) so the signal reaches the server process itself.constbin=process.env.MCP_BIN??createRequire(import.meta.url).resolve('chrome-devtools-mcp/package.json').replace(/package\.json$/,'build/src/bin/chrome-devtools-mcp.js');constbefore=clones();constserver=spawn('node',[bin,'--isolated','--no-usage-statistics'],{stdio: ['pipe','pipe','inherit']});constlines=createInterface({input: server.stdout});constpending=newMap();lines.on('line',l=>{constmsg=JSON.parse(l);pending.get(msg.id)?.(msg);});letnextId=1;constrpc=(method,params)=>newPromise(resolve=>{constid=nextId++;pending.set(id,resolve);server.stdin.write(JSON.stringify({jsonrpc: '2.0', id, method, params})+'\n');});awaitrpc('initialize',{protocolVersion: '2025-06-18',capabilities: {},clientInfo: {name: 'repro',version: '0'}});server.stdin.write(JSON.stringify({jsonrpc: '2.0',method: 'notifications/initialized'})+'\n');awaitrpc('tools/call',{name: 'list_pages',arguments: {}});constduring=clones();constchromePath=execFileSync('sh',['-c',`ps -axo pid=,ppid=,command= | awk '$2==${server.pid}' | grep -v crashpad | sed -E 's/^ *[0-9]+ +[0-9]+ +//; s/ --.*//' | head -1`]).toString().trim();constexited=newPromise(resolve=>server.on('exit',resolve));if(mode==='stdin')server.stdin.end();elseserver.kill(mode);awaitexited;awaitsleep(8000);// give Chrome time to delete its clone on a graceful exitconstafter=clones();console.log(`chrome launched from: ${chromePath||'unknown'}`);if(during<=before){// Chrome only clones itself on macOS 14+ stable/beta builds; no clone means nothing to leak.console.log(`${mode}: before=${before} during=${during} after=${after} -> INCONCLUSIVE (Chrome made no code_sign_clone)`);process.exit(2);}console.log(`${mode}: before=${before} during=${during} after=${after} -> ${after>before ? 'LEAKED' : 'clean'}`);process.exit(after>before ? 1 : 0);
Quick correction and an update after an independent re-test (separate agent, fresh install, Node 22 + 24, tracking the clone directory names rather than counts):
Scope, narrowed: the leak happens when the MCP server is stopped by a signal (SIGTERM/SIGINT/SIGHUP) after Chrome has launched and created a clone. A normal stdin-close shutdown cleans up fine, so "every session" in my first post was too broad. Also, sending SIGINT or SIGHUP directly to Chrome cleans up; only a direct SIGTERM leaks, because it goes through SessionEnding(), which exits immediately.
Root cause, unchanged: Puppeteer's default handleSIGTERM/SIGINT/SIGHUP SIGKILLs Chrome's process group before the MCP's own shutdown() → browser.close() finishes. SIGTERM shutdown completed in 33–50 ms, so the 5 s timeout isn't involved. Leaked clones were still present after ~6 min; clean runs remove them in ~0.3 s. With the three options set to false in puppeteer.launch(), SIGTERM/SIGINT/SIGHUP were all clean.
Repro fix: the earlier script printed counts even if list_pages failed (Chrome never launched), which would also produce before=1 during=1 after=1. It now exits with code 3 and prints the error in that case. Exit codes: 0 = clean, 1 = leaked, 2 = inconclusive (no clone created), 3 = tool call failed.
Could you re-run the updated script (below) and share its output, including the chrome launched from: line?
repro.mjs (updated)
// Repro for ChromeDevTools/chrome-devtools-mcp#3154 (macOS only).// Launches the MCP server over stdio, makes it start Chrome, sends a signal,// then counts Chrome code_sign_clone directories left behind.//// npm i chrome-devtools-mcp@latest// node repro.mjs [SIGTERM|SIGINT|SIGHUP|stdin] (default SIGTERM)// MCP_BIN=/path/to/build/src/bin/chrome-devtools-mcp.js node repro.mjs//// Uses stable Chrome (the default channel); Chrome for Testing makes no clone.import{spawn,execFileSync}from'node:child_process';import{readdirSync,existsSync}from'node:fs';import{dirname,join}from'node:path';import{setTimeoutassleep}from'node:timers/promises';import{createInterface}from'node:readline';import{createRequire}from'node:module';constmode=process.argv[2]??'SIGTERM';consttempDir=execFileSync('getconf',['DARWIN_USER_TEMP_DIR']).toString().trim();constcloneDir=join(dirname(tempDir),'X','com.google.Chrome.code_sign_clone');constclones=()=>existsSync(cloneDir) ? readdirSync(cloneDir).filter(d=>d.startsWith('code_sign_clone.')).length : 0;// Run node directly (not via npx) so the signal reaches the server process itself.constbin=process.env.MCP_BIN??createRequire(import.meta.url).resolve('chrome-devtools-mcp/package.json').replace(/package\.json$/,'build/src/bin/chrome-devtools-mcp.js');constbefore=clones();constserver=spawn('node',[bin,'--isolated','--no-usage-statistics'],{stdio: ['pipe','pipe','inherit']});constlines=createInterface({input: server.stdout});constpending=newMap();lines.on('line',l=>{constmsg=JSON.parse(l);pending.get(msg.id)?.(msg);});letnextId=1;constrpc=(method,params)=>newPromise(resolve=>{constid=nextId++;pending.set(id,resolve);server.stdin.write(JSON.stringify({jsonrpc: '2.0', id, method, params})+'\n');});awaitrpc('initialize',{protocolVersion: '2025-06-18',capabilities: {},clientInfo: {name: 'repro',version: '0'}});server.stdin.write(JSON.stringify({jsonrpc: '2.0',method: 'notifications/initialized'})+'\n');constcall=awaitrpc('tools/call',{name: 'list_pages',arguments: {}});if(call.error||call.result?.isError){// Chrome never launched, so the clone counts below would mean nothing.console.log(`list_pages failed: ${JSON.stringify(call.error??call.result.content)}`);server.kill('SIGKILL');process.exit(3);}constduring=clones();constchromePath=execFileSync('sh',['-c',`ps -axo pid=,ppid=,command= | awk '$2==${server.pid}' | grep -v crashpad | sed -E 's/^ *[0-9]+ +[0-9]+ +//; s/ --.*//' | head -1`]).toString().trim();constexited=newPromise(resolve=>server.on('exit',resolve));if(mode==='stdin')server.stdin.end();elseserver.kill(mode);awaitexited;awaitsleep(8000);// give Chrome time to delete its clone on a graceful exitconstafter=clones();console.log(`chrome launched from: ${chromePath||'unknown'}`);if(during<=before){// Chrome only clones itself on macOS 14+ stable/beta builds; no clone means nothing to leak.console.log(`${mode}: before=${before} during=${during} after=${after} -> INCONCLUSIVE (Chrome made no code_sign_clone)`);process.exit(2);}console.log(`${mode}: before=${before} during=${during} after=${after} -> ${after>before ? 'LEAKED' : 'clean'}`);process.exit(after>before ? 1 : 0);
Fair point, thanks. I checked what my client actually does. Logging the MCP's stdin and signals during a real Codex CLI 0.162.1 session shows Codex sends SIGTERM first and closes stdin ~40 ms later, which is the reverse of the spec's order. So the trigger is my client, and a spec-compliant client wouldn't hit this. I've reported it to Codex on their existing shutdown issue: openai/codex#48524 (comment)
I'd still suggest the one-line change as hardening: the server already registers SIGTERM/SIGINT/SIGHUP handlers that run a graceful browser.close(), but Puppeteer's default handlers SIGKILL Chrome first, so those handlers can't do their job. SIGTERM is also the spec's escalation step, and Ctrl+C on a terminal-launched client delivers SIGINT to the whole process group. Passing handleSIGINT/SIGTERM/SIGHUP: false to puppeteer.launch() makes the existing handlers work as intended. Totally fine if you'd rather close this as a client issue.
@bezlant I will check next week: just want to avoid a whac-a-mole game in case not handling signals would result in additional regressions like hanging or leaking Chrome in some situations.
Activity
OrKoN commentedon Oct 15, 2026
this is how the browser is closed in the latest version which sounds like the suggested fix:
can you provide a scripted reproduction to avoid ambiguities?
bezlant commentedon Oct 15, 2026
Thanks! I re-tested on 1.11.0 with a scripted repro. The graceful
browser.close()path is there, but it loses a race:BrowserManagercallspuppeteer.launch()withouthandleSIGINT/handleSIGTERM/handleSIGHUP: false, so Puppeteer's own signal handler also fires on the same signal and synchronously runsprocess.kill(-pid, 'SIGKILL')on Chrome's process group beforeshutdown()→browser.close()completes. Chrome only deletes itscode_sign_cloneon a graceful close, so it leaks.Results (stable Chrome 155, macOS 27, Apple Silicon):
handleSIGINT/SIGTERM/SIGHUP: falseinpuppeteer.launch()Suggested fix: pass
handleSIGINT: false, handleSIGTERM: false, handleSIGHUP: falsetopuppeteer.launch()inBrowserManager.js, sincechrome-devtools-mcp-main.jsalready handles those signals itself.Repro:
npm i chrome-devtools-mcp@latest && node repro.mjs SIGTERM(printsLEAKEDorclean; exit code 1 on leak).repro.mjs
OrKoN commentedon Oct 16, 2026
I am not able to reproduce:
As far as I know Puppeteer also first tries graceful close before killing the hanging browser.
bezlant commentedon Oct 16, 2026
Thanks for running it! In your output
duringequalsbefore(1 → 1), so Chrome never created a code-sign clone, which means that run can't show the leak. Per Chromium'scode_sign_clone_manager.mm,kMacAppCodeSignCloneis enabled by default but compiled out for Chrome for Testing, and the clone is only removed from~CodeSignCloneManagerduring a graceful shutdown. A SIGKILL skips it, and/var/folders/…/Xis only wiped at reboot, so leaks pile up over uptime (53 after 12 days here). Could you check whether the launched Chrome is Chrome for Testing or a non-stable build? The updated repro below prints the executable path and reportsINCONCLUSIVEwhen no clone is created.On my machine (stable Chrome 155.0.8059.84 from
/Applications, macOS 27.0.1):before=6 during=7 after=7 → LEAKED. For SIGTERM/SIGHUP,@puppeteer/browserscallsclose(), which goes straight tokill()and sendsprocess.kill(-pid, 'SIGKILL')(launch.ts L436–450, L492). There's no CDPBrowser.closeon that path. PassinghandleSIGTERM/SIGINT/SIGHUP: falsetopuppeteer.launch()lets the MCP's ownshutdown()→browser.close()run, and then the clone is cleaned up (4/4 here).repro.mjs (updated)
bezlant commentedon Oct 16, 2026
Quick correction and an update after an independent re-test (separate agent, fresh install, Node 22 + 24, tracking the clone directory names rather than counts):
SessionEnding(), which exits immediately.handleSIGTERM/SIGINT/SIGHUPSIGKILLs Chrome's process group before the MCP's ownshutdown()→browser.close()finishes. SIGTERM shutdown completed in 33–50 ms, so the 5 s timeout isn't involved. Leaked clones were still present after ~6 min; clean runs remove them in ~0.3 s. With the three options set tofalseinpuppeteer.launch(), SIGTERM/SIGINT/SIGHUP were all clean.list_pagesfailed (Chrome never launched), which would also producebefore=1 during=1 after=1. It now exits with code 3 and prints the error in that case. Exit codes: 0 = clean, 1 = leaked, 2 = inconclusive (no clone created), 3 = tool call failed.Could you re-run the updated script (below) and share its output, including the
chrome launched from:line?repro.mjs (updated)
OrKoN commentedon Oct 17, 2026
@bezlant I will check but closing a stdio server this way is not according to the spec https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/stdio#shutdown what is the reason for not closing the stdio and shutting down via the signal instead?
bezlant commentedon Oct 17, 2026
Fair point, thanks. I checked what my client actually does. Logging the MCP's stdin and signals during a real Codex CLI 0.162.1 session shows Codex sends SIGTERM first and closes stdin ~40 ms later, which is the reverse of the spec's order. So the trigger is my client, and a spec-compliant client wouldn't hit this. I've reported it to Codex on their existing shutdown issue: openai/codex#48524 (comment)
I'd still suggest the one-line change as hardening: the server already registers SIGTERM/SIGINT/SIGHUP handlers that run a graceful
browser.close(), but Puppeteer's default handlers SIGKILL Chrome first, so those handlers can't do their job. SIGTERM is also the spec's escalation step, and Ctrl+C on a terminal-launched client delivers SIGINT to the whole process group. PassinghandleSIGINT/SIGTERM/SIGHUP: falsetopuppeteer.launch()makes the existing handlers work as intended. Totally fine if you'd rather close this as a client issue.OrKoN commentedon Oct 17, 2026
@bezlant I will check next week: just want to avoid a whac-a-mole game in case not handling signals would result in additional regressions like hanging or leaking Chrome in some situations.
fix: disable Puppeteer signal handlers for launched browsers (ChromeD…
chore(main): release chrome-devtools-mcp 1.12.0 (#3168)