René's URL Explorer Experiment


Title: fix(debug-ios): make the CDP proxy pick a free port and survive reconnects by rigor789 · Pull Request #6177 · NativeScript/nativescript-cli · GitHub

Open Graph Title: fix(debug-ios): make the CDP proxy pick a free port and survive reconnects by rigor789 · Pull Request #6177 · NativeScript/nativescript-cli

X Title: fix(debug-ios): make the CDP proxy pick a free port and survive reconnects by rigor789 · Pull Request #6177 · NativeScript/nativescript-cli

Description: What is the current behavior? Port in use: isPortAvailable checks localhost, but since #5788 the WebSocket server binds every interface. On macOS those don't conflict, so a taken port passes the check, the listen fails with EADDRINUSE, and the CLI crashes. Two ns debug sessions are enough to hit it. Reconnects: the connection lock was released on the connection event, which never fires for a client that drops during the handshake. proper-lockfile keeps refreshing a lock while its process lives, so it never goes stale, and every later client fails after about 10 seconds with Timeout while waiting for lock and a 401 until the CLI exits. Separately, a late close from a replaced client could destroy the socket its successor had just received. What is the new behavior? isPortAvailable tests 127.0.0.1, ::1, 0.0.0.0 and ::, and the proxy moves to the next port if the bind still fails. Android's debug port uses the same check. Connections go through an in-process queue instead of a file lock. Each session only cleans up after itself. The newest client takes over, and the previous one is closed with Replaced by a newer debugger client. Port service timers are now cleared. The typeof timer === "number" check never matched in Node, which produced false not able to get inspector socket port warnings. The proxy only listens on 127.0.0.1 and ::1, and rejects browser origins other than DevTools and localhost with a 403. It used to accept connections from the network and from any web page, and the debugger can run any code in the app. Clients without an origin, like VS Code's debug adapter, are still accepted. Only one client at a time is supported, as before. The runtime serves a single frontend and ios-device-lib keeps one forwarded connection per device. Testing Stress test against a real app on an iOS 26.2 simulator, 5 rounds per scenario: Scenario Old proxy This PR Connect, reconnect, killed client, refresh overlap, takeover 5/5 each 5/5 each Client drops during handshake 0/5 5/5 5 clients connect at once 0/5 5/5, exactly one left connected With another process on 41000, this PR came up on 41001. Unit tests are included. On an iPad, every scenario passed until the app stopped responding 80–140 seconds into a run, then every connection got a 401. It happened in 3 of 4 runs, varied in timing, hit a plain connect/close loop too, and left no crash report. The iPad locking is the likely cause, but that isn't proven, and recovery after waking wasn't tested. Security checks against the running proxy: 127.0.0.1, ::1 and localhost connect, a https://evil.example origin gets a 403, and the machine's LAN address is refused. Real Chrome DevTools sends devtools://devtools, captured from a headless Chrome, which is on the allowed list. A full DevTools session through the proxy and VS Code's debug adapter weren't run. The Safari --inspector TCP proxy is a separate path and is unchanged. Part of a stack Base: #6176. Next: #6178. Summary by CodeRabbit Bug Fixes Improved iOS debugger connections during client reconnections and disconnects, helping keep the active session stable and recover from interrupted handshakes. Improved handling of occupied ports so the debugger can retry on another port when available. Improved port availability checks across common network addresses, reducing incorrect reports that a port is free. Restricted debugger connections to supported origins and loopback addresses, while continuing to allow valid DevTools connections. Improved handling of simultaneous clients and session replacements to prevent an old connection from disrupting the active session.

Open Graph Description: What is the current behavior? Port in use: isPortAvailable checks localhost, but since #5788 the WebSocket server binds every interface. On macOS those don't conflict, so a taken port passes th...

X Description: What is the current behavior? Port in use: isPortAvailable checks localhost, but since #5788 the WebSocket server binds every interface. On macOS those don't conflict, so a taken port passe...

Opengraph URL: https://github.com/NativeScript/nativescript-cli/pull/6177

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:2907e4fb-7366-2aed-4cf0-65eb2bd9640c
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idDD08:2BE220:173B43B:1F06103:6B014422
html-safe-nonce7756789dab4eb69ebdb3ce6c13f8d78d5535ff0342498ee4aafa317d31ddd277
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDA4OjJCRTIyMDoxNzNCNDNCOjFGMDYxMDM6NkIwMTQ0MjIiLCJ2aXNpdG9yX2lkIjoiNTgxMjQzMTcxOTM4MjQ2NzYxOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac5820feefef94fb21ec7192e012f3f9e4d7ac95ac6db72da2af5c93af321bda69
hovercard-subject-tagpull_request:5087898790
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/NativeScript/nativescript-cli/pull/6177/files
twitter:imagehttps://avatars.githubusercontent.com/u/879060?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/879060?s=400&v=4
og:image:altWhat is the current behavior? Port in use: isPortAvailable checks localhost, but since #5788 the WebSocket server binds every interface. On macOS those don't conflict, so a taken port passes th...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/NativeScript/nativescript-cli git https://github.com/NativeScript/nativescript-cli.git
octolytics-dimension-user_id7392261
octolytics-dimension-user_loginNativeScript
octolytics-dimension-repository_id21347346
octolytics-dimension-repository_nwoNativeScript/nativescript-cli
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id21347346
octolytics-dimension-repository_network_root_nwoNativeScript/nativescript-cli
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/NativeScript/nativescript-cli/pull/6177/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2Fnativescript-cli%2Fpull%2F6177%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2Fnativescript-cli%2Fpull%2F6177%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=NativeScript%2Fnativescript-cli
Reloadhttps://github.com/NativeScript/nativescript-cli/pull/6177/files
Reloadhttps://github.com/NativeScript/nativescript-cli/pull/6177/files
Reloadhttps://github.com/NativeScript/nativescript-cli/pull/6177/files
NativeScripthttps://github.com/NativeScript
nativescript-clihttps://github.com/NativeScript/nativescript-cli
Codehttps://github.com/NativeScript/nativescript-cli
Issues357 (357)https://github.com/NativeScript/nativescript-cli/issues
Pull requests37 (37)https://github.com/NativeScript/nativescript-cli/pulls
Actionshttps://github.com/NativeScript/nativescript-cli/actions
Projectshttps://github.com/NativeScript/nativescript-cli/projects
Security and qualityhttps://github.com/NativeScript/nativescript-cli/security
Insightshttps://github.com/NativeScript/nativescript-cli/insights
Sign up for GitHub https://github.com/signup?return_to=%2FNativeScript%2Fnativescript-cli%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FNativeScript%2Fnativescript-cli%2Fissues%2Fnew%2Fchoose
edusperonihttps://github.com/edusperoni
fix/ios-device-double-launchhttps://github.com/NativeScript/nativescript-cli/tree/fix/ios-device-double-launch
fix/ios-debug-proxyhttps://github.com/NativeScript/nativescript-cli/tree/fix/ios-debug-proxy
Conversation 6 https://github.com/NativeScript/nativescript-cli/pull/6177
Commits 4 https://github.com/NativeScript/nativescript-cli/pull/6177/commits
Checks 12 https://github.com/NativeScript/nativescript-cli/pull/6177/checks
Files changed https://github.com/NativeScript/nativescript-cli/pull/6177/files
Please reload this pagehttps://github.com/NativeScript/nativescript-cli/pull/6177/files
fix(debug-ios): make the CDP proxy pick a free port and survive reconnects https://github.com/NativeScript/nativescript-cli/pull/6177/files#top
Show all changes 4 commits https://github.com/NativeScript/nativescript-cli/pull/6177/files
54bb719 fix(debug-ios): make the CDP proxy pick a free port and survive recon… rigor789 Oct 30, 2026 https://github.com/NativeScript/nativescript-cli/pull/6177/commits/54bb71978b01abc58095d7a1a8fe783c7dd6a83e
88cb51d fix(debug-ios): only accept debugger connections from this machine an… rigor789 Oct 30, 2026 https://github.com/NativeScript/nativescript-cli/pull/6177/commits/88cb51d2c18029a70d04d4e7632b8e7f32c1fded
1aa7b02 fix(debug-ios): clean up and exit when the app's socket closes rigor789 Oct 30, 2026 https://github.com/NativeScript/nativescript-cli/pull/6177/commits/1aa7b02f6ba86f6fb1e65a9ac7957617baeb9f25
572af52 test(net): skip unavailable addresses through vitest's test context rigor789 Oct 30, 2026 https://github.com/NativeScript/nativescript-cli/pull/6177/commits/572af5297aa74b305a973eafd7851173c5702c3a
Clear filters https://github.com/NativeScript/nativescript-cli/pull/6177/files
Please reload this pagehttps://github.com/NativeScript/nativescript-cli/pull/6177/files
Please reload this pagehttps://github.com/NativeScript/nativescript-cli/pull/6177/files
net-service.ts https://github.com/NativeScript/nativescript-cli/pull/6177/files#diff-01558065adf8b925846e7dc9c6e07fa48732d307494f043436866b3da335ce26
net-service.ts https://github.com/NativeScript/nativescript-cli/pull/6177/files#diff-b7fc538f5a6187c744af81865ad2a324d914b4d55c6434110a65cbe263274a8b
app-debug-socket-proxy-factory.ts https://github.com/NativeScript/nativescript-cli/pull/6177/files#diff-ddc2ce7f8ada9e2ce8eba6d4e7261b412ec9729725ed7c8bf35ec4d935d61557
ios-debugger-port-service.ts https://github.com/NativeScript/nativescript-cli/pull/6177/files#diff-827ee778bcb7ceb3cb25e2cf85ce3f88979a488def60178cf6ec9f284b333850
app-debug-socket-proxy-factory.ts https://github.com/NativeScript/nativescript-cli/pull/6177/files#diff-b0a6bdec7d63d9ad128dd044d12ea02c80d5b1f3b3d864b28b1aa50f608e35b2
lib/common/services/net-service.tshttps://github.com/NativeScript/nativescript-cli/pull/6177/files#diff-01558065adf8b925846e7dc9c6e07fa48732d307494f043436866b3da335ce26
View file https://github.com/NativeScript/nativescript-cli/blob/572af5297aa74b305a973eafd7851173c5702c3a/lib/common/services/net-service.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/nativescript-cli/pull/6177/{{ revealButtonHref }}
https://github.com/NativeScript/nativescript-cli/pull/6177/files#diff-01558065adf8b925846e7dc9c6e07fa48732d307494f043436866b3da335ce26
https://github.com/NativeScript/nativescript-cli/pull/6177/files#diff-01558065adf8b925846e7dc9c6e07fa48732d307494f043436866b3da335ce26
lib/common/test/unit-tests/services/net-service.tshttps://github.com/NativeScript/nativescript-cli/pull/6177/files#diff-b7fc538f5a6187c744af81865ad2a324d914b4d55c6434110a65cbe263274a8b
View file https://github.com/NativeScript/nativescript-cli/blob/572af5297aa74b305a973eafd7851173c5702c3a/lib/common/test/unit-tests/services/net-service.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/nativescript-cli/pull/6177/{{ revealButtonHref }}
https://github.com/NativeScript/nativescript-cli/pull/6177/files#diff-b7fc538f5a6187c744af81865ad2a324d914b4d55c6434110a65cbe263274a8b
Please reload this pagehttps://github.com/NativeScript/nativescript-cli/pull/6177/files
https://github.com/NativeScript/nativescript-cli/pull/6177/files#diff-b7fc538f5a6187c744af81865ad2a324d914b4d55c6434110a65cbe263274a8b
Please reload this pagehttps://github.com/NativeScript/nativescript-cli/pull/6177/files
Please reload this pagehttps://github.com/NativeScript/nativescript-cli/pull/6177/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.