Skip to content

fix: consume stdout concurrently with process exit in auth login#15058

Merged
thdxr merged 1 commit intoanomalyco:devfrom
Ayushlm10:fix/auth-login-token
Feb 25, 2026
Merged

fix: consume stdout concurrently with process exit in auth login#15058
thdxr merged 1 commit intoanomalyco:devfrom
Ayushlm10:fix/auth-login-token

Conversation

@Ayushlm10
Copy link
Copy Markdown
Contributor

@Ayushlm10 Ayushlm10 commented Feb 25, 2026

Issue for this PR

Closes #15057

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

opencode auth login <url> stores an empty token in auth.json because the code awaits proc.exited before starting to read proc.stdout. By the time text(proc.stdout) runs, the child process has already exited and the OS has closed the pipe — the stream data is lost.
The fix reads stdout concurrently with the process exit via Promise.all, so the stream is actively consumed while the process is still running.

How did you verify your code works?

  1. Ran opencode auth login <url> on dev (unfixed) —> confirmed auth.json has "token": ""
  2. Switched to fix branch, cleared auth.json, ran again —> confirmed token is now populated with the actual value

Screenshots / recordings

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

The auth login flow awaited proc.exited before reading proc.stdout,
causing the stream to close before consumption. The token was lost,
resulting in an empty string stored in auth.json.

Read stdout in parallel with proc.exited via Promise.all, matching the
pattern already used by Process.run().
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Feb 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@thdxr thdxr enabled auto-merge (squash) February 25, 2026 13:22
@thdxr thdxr disabled auto-merge February 25, 2026 13:22
@thdxr thdxr merged commit 088a81c into anomalyco:dev Feb 25, 2026
26 of 28 checks passed
neostfox pushed a commit to neostfox/opencode that referenced this pull request Feb 26, 2026
sebishogun pushed a commit to sebishogun/opencode that referenced this pull request Feb 26, 2026
jonathanmiddleton pushed a commit to jonathanmiddleton/opencode that referenced this pull request Mar 10, 2026
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.

auth login stores empty token in auth.json

2 participants