Skip to content

fix(cli): prevent login command from hanging after successful auth - #80

Merged
Brooooooklyn merged 1 commit into
mainfrom
04-03-fix_cli_prevent_login_command_from_hanging_after_successful_auth
Apr 3, 2026
Merged

Brooooooklyn merged 1 commit into
mainfrom
04-03-fix_cli_prevent_login_command_from_hanging_after_successful_auth

Conversation

@shulaoda

@shulaoda shulaoda commented Apr 3, 2026

Copy link
Copy Markdown
Member

Summary

Unref incoming sockets on the OAuth callback server so the process exits immediately after login completes, instead of waiting for the browser's HTTP keep-alive connection to time out

Root cause

After a successful login, server.close() stops accepting new connections but doesn't close existing ones. The browser's keep-alive connection keeps the socket alive, which keeps the Node.js event loop running — causing the CLI to hang for several seconds after printing "Token saved."

Fix

socket.unref() on each incoming connection tells Node.js not to keep the process alive solely for that socket. After resolve(token) and the remaining CLI output (saveToken, outro), the event loop has nothing left to do and the process exits cleanly.

@Brooooooklyn
Brooooooklyn merged commit 6555960 into main Apr 3, 2026
6 checks passed
@Brooooooklyn
Brooooooklyn deleted the 04-03-fix_cli_prevent_login_command_from_hanging_after_successful_auth branch April 3, 2026 13:30
cpojer pushed a commit that referenced this pull request Sep 11, 2026
When a WebSocket Durable Object class disappeared from the deploy
manifest (e.g. due to a build artifact change, manifest corruption,
or intentional removal), enrichWebSocketManifest() would emit a
`deletedClasses` migration step. Cloudflare interprets `deleted_classes`
as an irreversible destruction of the DO namespace and all its stored
data — active connections immediately fail with "Durable Object
Namespace was deleted".

Per Cloudflare's documentation: "Do not run a Delete migration on a
class without first ensuring that you are not relying on the Durable
Objects within that Worker anymore." Deletion should be an explicit,
opt-in action (like wrangler's --delete-class flag), never automated.

This change:
- Removes `deletedClasses` computation from `enrichWebSocketManifest()`
- Removes `deleted_classes` emission from `buildWebSocketUploadMigrations()`
- Computes `newClasses` against the full migration history (all classes
  ever created via `newClasses`), not just the previous manifest's class
  set. This prevents re-emitting `new_classes` for a class that was
  previously created, temporarily removed, then re-added — which
  Cloudflare rejects with "Cannot apply new-class migration ... already
  depended on existing Durable Objects"
- Skips emitting a migration step entirely when there are no genuinely
  new classes (avoids empty `{}` steps sent to Cloudflare)
- Classes removed from the manifest are simply dropped from the class
  list without destroying their Cloudflare namespace. Orphaned
  namespaces are harmless and can be cleaned up explicitly later.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Brooooooklyn added a commit that referenced this pull request Nov 24, 2026
…, show the last bypass

- waiting_scan copy (API and CLI) says when it waits for a deploy going live
  or for the project's Zero Trust row, not only for a scan (#75, #86).
- The CLI bypass sends the request it saw; the route takes `requestId`, so a
  bypass that loses to a protect gets 409 `public request closed` with its
  state instead of "no public request ... run public" (#72).
- Bypass refusals keep the API code, status and blockers in `--json` (#93).
- GET /projects/:id/zero-trust returns `lastBypass` (reason for deploy and
  up) and `zero-trust status` prints a "Last bypass" line (§13.3).
- `protect` that cancels an open request prints "Public request canceled.
  <slug> stays protected."; a held `public` prints the CLI request lines and
  "Check it: void project zero-trust status" (§11.4, §13.3, #80).
- A public-only Zero Trust switch with the gate on is refused with 409
  `security public gate on` before the existing-projects check (#64).
- Copy nits: "finishes" for one going-public project, the requester in the
  cancel preview, "failing since" from a stored start of the probe failure,
  bypass during a Zero Trust change says "Try again after it ends", and a
  passed request drops its held reason (#65, #87, #89, §5.2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants