Skip to content

Close the loopback sign-in connection and let the OS pick test debug ports - #327

Merged
Twest2 merged 1 commit into
mainfrom
fix/ci-flaky-ports
Nov 17, 2026
Merged

Twest2 merged 1 commit into
mainfrom
fix/ci-flaky-ports

Conversation

@Twest2

@Twest2 Twest2 commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Issue

Closes #326

Summary

Two CI jobs failed intermittently on pull requests that never touched the code involved, which made every red check ambiguous. Both root causes are fixed here. Users of the app get one real improvement: a browser sign-in no longer leaves the browser holding an idle connection to a server StepForge has already stopped.

Changes

  • app/cloud-account.js answers the loopback OAuth redirect with Connection: close. The redirect is answered exactly once and the server shuts down straight after, so connection reuse has nothing to reuse. Without it the client kept a pooled socket to a dead server, and the HTTP parser later threw Cannot destructure property 'socket' of 'parser.deref(...)' after the owning test had ended, which marked the whole cloud-accounts test file not ok on Windows even though all its subtests passed.
  • tests/e2e/lib/driver.js stops reserving debug ports before launching. It now passes --remote-debugging-port=0 and --inspect=0 and reads the ports back after the app has bound them: the DevTools port from the DevToolsActivePort file Chromium writes into the user-data folder, and the inspector port from the Debugger listening on ws://… line Node prints. The old freePort() helper bound port 0, closed the socket, and handed the bare number to Electron, leaving a window in which another process could take the port; that produced bind() failed: Address already in use (98) / Cannot start http server for devtools, and with no retry the driver spent its full 30s timeout before failing the test that happened to be launching.
  • freePort() is removed rather than left unused, since pre-reserving a port is the bug.
  • New unit test covering the sign-in connection behaviour.

Area

  • Cloud sync (Google Drive, OneDrive, Dropbox, Nextcloud / WebDAV)
  • Tests

Testing

  • bash tests/run_test.sh passes

  • Tested manually (describe below)

  • npm test: 1627 pass, 0 fail, 26 skipped.

  • bash tests/run_test.sh: All tests passed. The UI suite and startup smoke check skip on this host because xvfb-run is not installed, so the e2e tests were run separately against a real display.

  • The new unit test is a real regression test: with the Connection: close line removed it fails, and it fails with the same "generated asynchronous activity after the test ended" error class seen in CI. With the fix, 20/20 pass in that file.

  • e2e with the new driver: editor, library, exports, toolbar, ai-settings and clipboard are 18/18 pass, including Move step up and Move step down reorder the steps on disk, the test that failed in CI.

  • The canvas (2) and settings (1) e2e tests fail on this host both with and without this change, because they were run against my real desktop display where the pointer and compositor are shared. They are unaffected by this change and expected to pass on CI's private Xvfb display.

  • Verified the port mechanism directly: launching Electron with --remote-debugging-port=0 writes the real bound port to DevToolsActivePort, and /json/list on that port returns the StepForge renderer target. --inspect=0 prints the inspector port on stderr.

Screenshots or recordings

N/A — no interface changes.

Rollout notes

None.

Checklist

  • Linked to an issue above
  • Scope is limited to that issue
  • New behavior has tests that check real output
  • Docs updated for anything users will notice
  • New interface text is in t(), and npm run translations lists nothing missing
  • Anything that still needs manual verification is listed above
  • No new network calls, dependencies, or third-party branding
  • Follow-up work is tracked in an issue

@Twest2

Twest2 commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T19:38:17.628796Z bb47fc5 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: bb47fc5054

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Twest2
Twest2 merged commit ced1ed7 into main Nov 17, 2026
10 of 11 checks passed
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.

Flaky CI: loopback sign-in socket and reserved e2e debug ports

1 participant