Title: fix: honour --reconnection-grace-time when the browser closes by hugodeco · Pull Request #7956 · coder/code-server · GitHub
Open Graph Title: fix: honour --reconnection-grace-time when the browser closes by hugodeco · Pull Request #7956 · coder/code-server
X Title: fix: honour --reconnection-grace-time when the browser closes by hugodeco · Pull Request #7956 · coder/code-server
Description: Fixes #7955 Summary --reconnection-grace-time (#7678) cannot currently deliver what it documents, for two independent reasons: Closing the tab bypasses the grace time. BrowserLifecycleService runs the workbench shutdown on pagehide/beforeunload, disposing the remote connection gracefully. ManagementConnection treats a graceful dispose as a finished client and calls _cleanResources() immediately — the grace time is never consulted, so the session dies with the tab however the flag is set. A second connection cuts it to 5 minutes. Every new connection calls shortenReconnectionGraceTimeIfNecessary() on all disconnected connections, scheduling ProtocolConstants.ReconnectionShortGraceTime. Opening a second tab is enough to shorten a deliberately long grace time. This adds patches/session-preservation.diff, which makes the configured grace time authoritative. Changes lib/vscode/src/vs/workbench/services/lifecycle/browser/lifecycleService.ts pagehide persists UI state (storageService.flush(WillSaveStateReason.SHUTDOWN)) instead of unloading. A browser-driven unload no longer tears the workbench down. The veto handler is only passed on the browser path, so that is the discriminator: a beforeunload veto is still honoured, and an explicit in-product shutdown (shutdown(), which passes no veto handler) still unloads normally. lib/vscode/src/vs/server/node/remoteExtensionHostAgentServer.ts The grace time is only shortened when it was left at or below ProtocolConstants.ReconnectionGraceTime. Installations that never set the flag keep Code's stock behaviour; only an operator who deliberately raised it opts into the longer wait. Also updates the unreleased changelog section. Test plan quilt pop -a && quilt push -a — full series applies cleanly with the new patch npm run typecheck-client in lib/vscode — passes npm run lint:ts — passes npm run test:unit — 331/332; the one failure (should unlink a socket before listening on the socket, expecting EACCES) is environmental, from running as root, and exercises src/node/app.ts, which this PR does not touch npm run valid-layers-check fails identically with and without this patch (pre-existing, in network.ts / extensionResourceLoader.ts) Behaviour verified in production on 4.128.0: with --reconnection-grace-time 2592000, sessions survive closing the browser and reconnect on return I was not able to run a full product build on the machine I had available (disk), so a CI build is the remaining check. 🤖 Generated with Claude Code
Open Graph Description: Fixes #7955 Summary --reconnection-grace-time (#7678) cannot currently deliver what it documents, for two independent reasons: Closing the tab bypasses the grace time. BrowserLifecycleService run...
X Description: Fixes #7955 Summary --reconnection-grace-time (#7678) cannot currently deliver what it documents, for two independent reasons: Closing the tab bypasses the grace time. BrowserLifecycleService run...
Opengraph URL: https://github.com/coder/code-server/pull/7956
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
| react-profiling | 0 |
| react-import-map | react,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-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:1f7b89b5-db85-b230-86ff-c25715e1723e |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D492:12691F:3C3B2E:50B61B:6B0437C4 |
| html-safe-nonce | cb20a741a27518f6a3af61f705720865a05dfd5fa9ef6e98794d5dff41e41d3d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENDkyOjEyNjkxRjozQzNCMkU6NTBCNjFCOjZCMDQzN0M0IiwidmlzaXRvcl9pZCI6IjY4OTIwNjAwMTk0MDAxMjg0NTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 738af76d100596184e0f4d5b23017a02224cce33755b648cde9482dd56b7f9f1 |
| hovercard-subject-tag | pull_request:4316753997 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/coder/code-server/pull/7956/files |
| twitter:image | https://avatars.githubusercontent.com/u/2934665?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/2934665?s=400&v=4 |
| og:image:alt | Fixes #7955 Summary --reconnection-grace-time (#7678) cannot currently deliver what it documents, for two independent reasons: Closing the tab bypasses the grace time. BrowserLifecycleService run... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9185ccfefd80c1ff2d9ddcdb0cd2becf46b5a1efbbf30741a895e4bb8de25e64 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/coder/code-server git https://github.com/coder/code-server.git |
| octolytics-dimension-user_id | 95932066 |
| octolytics-dimension-user_login | coder |
| octolytics-dimension-repository_id | 172953845 |
| octolytics-dimension-repository_nwo | coder/code-server |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 172953845 |
| octolytics-dimension-repository_network_root_nwo | coder/code-server |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 06dc448a76fe4751ac1db26524aefa3aa3e889a8 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width