Skip to content

fix(cli): match host service PORT env var name in spawn#3640

Merged
saddlepaddle merged 1 commit into
mainfrom
super-448-match-host-service-p-2026-04-22-05-40-47
Apr 22, 2026
Merged

fix(cli): match host service PORT env var name in spawn#3640
saddlepaddle merged 1 commit into
mainfrom
super-448-match-host-service-p-2026-04-22-05-40-47

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented Apr 22, 2026

Summary

  • packages/cli/src/lib/host/spawn.ts passed the spawned host service port as HOST_SERVICE_PORT, but packages/host-service/src/env.ts reads PORT, so the CLI's --port flag (and the random free port chosen by findFreePort()) was silently ignored. The host always listened on the default 4879 while the CLI polled a different port, causing host start to fail with Host service failed to start within 10000ms.
  • Emit PORT alongside HOST_SERVICE_PORT so the host service picks up the CLI-selected port. Keeping the old name preserves backwards compatibility for any external reader.

Linear: https://linear.app/superset-sh/issue/SUPER-448

Test plan

  • bun run lint:fix && bun run format:check clean
  • bun --filter @superset/cli --filter @superset/host-service typecheck passes
  • Rebuild CLI (cd packages/cli && bun run scripts/build-dist.ts --target=linux-x64), extract tarball, run SUPERSET_HOST_BIN=<scratch>/bin/superset-host <scratch>/bin/superset host start — completes health check without --port

Summary by cubic

Set PORT when @superset/cli spawns the host service so it matches what @superset/host-service reads, fixing host start failures. The host now binds to the CLI-selected port (--port or a free port) instead of 4879, while keeping HOST_SERVICE_PORT for compatibility; aligns with Linear SUPER-448.

Written for commit c3aad63. Summary will update on new commits.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed host service initialization to properly configure the port environment variable when starting the runtime service.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1f95c769-25c5-4eee-957e-76ade0622c22

📥 Commits

Reviewing files that changed from the base of the PR and between 38a080c and c3aad63.

📒 Files selected for processing (1)
  • packages/cli/src/lib/host/spawn.ts

📝 Walkthrough

Walkthrough

A single environment variable, PORT, is added to the spawned superset-host process, set to the selected runtime port. The remainder of the process initialization and health-check polling logic remains unchanged.

Changes

Cohort / File(s) Summary
Environment Variable Injection
packages/cli/src/lib/host/spawn.ts
Added PORT environment variable injection to spawned superset-host process, set to the selected runtime port value.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A port now whispers to the spawned host,
Where numbers flow like carrots on a post,
One line of code, a tiny change so neat,
Makes the service dance to time's own beat! 🌱

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding the PORT environment variable to match what the host service reads, fixing a critical bug where the CLI-selected port was ignored.
Description check ✅ Passed The PR description provides comprehensive context including the bug explanation, the fix rationale, backwards compatibility consideration, linked issue, and detailed test plan covering lint, typecheck, and runtime verification.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch super-448-match-host-service-p-2026-04-22-05-40-47

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 22, 2026

Greptile Summary

This PR fixes a silent port mismatch bug in the host service spawn flow. The CLI was passing the selected port as HOST_SERVICE_PORT, but packages/host-service/src/env.ts reads PORT (with a default of 4879). This caused the host service to always bind on 4879 while the CLI polled the dynamically-selected port, resulting in the Host service failed to start within 10000ms error. The fix adds PORT: String(port) to the env block passed to the spawned process, alongside the existing HOST_SERVICE_PORT which is kept for backwards compatibility.

Confidence Score: 5/5

Safe to merge — single-line targeted fix with no side-effects.

The fix is a one-line addition that directly addresses the documented root cause. The host-service env schema (PORT with default(4879)) and the CLI spawn env block are the only two files involved, both have been read and verified. The change is backwards compatible (old HOST_SERVICE_PORT key is preserved), risk of regression is negligible.

No files require special attention.

Important Files Changed

Filename Overview
packages/cli/src/lib/host/spawn.ts Adds PORT env var to the spawned host-service process so it binds on the CLI-selected port instead of always defaulting to 4879.

Sequence Diagram

sequenceDiagram
    participant CLI as CLI (spawn.ts)
    participant OS as OS Kernel
    participant HS as Host Service (env.ts)

    CLI->>OS: findFreePort() → e.g. 51234
    CLI->>HS: spawn(hostBin, env={ PORT: "51234", HOST_SERVICE_PORT: "51234" })
    HS->>HS: createEnv() reads PORT=51234 ✅
    HS->>OS: listen on :51234
    CLI->>HS: GET /trpc/health.check on :51234
    HS-->>CLI: 200 OK

    Note over CLI,HS: Before fix: PORT was unset → host defaulted to 4879,<br/>CLI polled 51234 → timeout after 10 000 ms
Loading

Reviews (1): Last reviewed commit: "fix(cli): match host service PORT env va..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 22, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

@saddlepaddle saddlepaddle merged commit a4e1567 into main Apr 22, 2026
14 checks passed
@Kitenite Kitenite deleted the super-448-match-host-service-p-2026-04-22-05-40-47 branch May 6, 2026 04:52
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.

1 participant