Skip to content

fix: align runtime port fallbacks with canonical 4443 default — closes #477#542

Merged
melvincarvalho merged 1 commit into
gh-pagesfrom
issue-477-port-fallback-alignment
Jun 9, 2026
Merged

fix: align runtime port fallbacks with canonical 4443 default — closes #477#542
melvincarvalho merged 1 commit into
gh-pagesfrom
issue-477-port-fallback-alignment

Conversation

@melvincarvalho

Copy link
Copy Markdown
Contributor

Closes #477.

Bug

#245 changed the declared default port from 3000 → 4443 in src/config.js (April 2026), but four runtime fallbacks still read port || 3000. Programmatic embedders, tests that called startServer() with no port, and the package's main entry (src/index.js when PORT env is unset) all landed on 3000 instead of 4443 — an inconsistency that hid behind any caller that happened to pass a port.

The issue's list cited three locations in src/server.js; a fourth turned up at src/index.js:3 and is included.

Fix

Uses the author's preferred "one source of truth" shape from the issue body — import defaults from ./config.js and reference defaults.port so future port changes only touch one file.

File:line Was Becomes
src/server.js:879 options.port || 3000 options.port || defaults.port
src/server.js:1224 options.port || 3000 options.port || defaults.port
src/server.js:1235 startServer(port = 3000, ...) startServer(port = defaults.port, ...)
src/index.js:3 process.env.PORT || 3000 process.env.PORT || defaults.port

Plus an import { defaults } from './config.js' in each file (server.js didn't previously import from config.js).

Scope discipline

Port only. The adjacent '0.0.0.0' host literals in startServer's signature and src/index.js are NOT changed — they aren't part of this issue and the project style avoids piggybacking on focused fixes. Trivial follow-up if desired.

Verification

  • grep -nE '3000' src/server.js src/index.js → none
  • node --check on both files → OK
  • Full test suite: 917/917 passing
  • No existing test depended on 3000 as the port default — the only 3000 references in test/ are millisecond timeouts; actual port binding goes through getAvailablePort()

Refs

#245 changed the declared default port from 3000 → 4443 in
src/config.js (April 2026), but four runtime fallbacks still read
`port || 3000`. Programmatic embedders, tests that call startServer()
with no port, and the package's main entry (src/index.js when PORT
env is unset) all landed on 3000 instead of 4443 — an inconsistency
that hid behind any caller that happened to pass a port.

Fix uses the author's preferred 'one source of truth' shape from
the issue body: import `defaults` from ./config.js and reference
`defaults.port` so future port changes only touch config.js.

  - src/server.js:879   options.port || 3000     → || defaults.port
  - src/server.js:1224  options.port || 3000     → || defaults.port
  - src/server.js:1235  startServer(port=3000)   → port=defaults.port
  - src/index.js:3      process.env.PORT || 3000 → || defaults.port

Scope discipline: port only. The adjacent '0.0.0.0' host literals
stay as-is — they aren't part of this issue and a separate fix can
align them if desired.

Verification:
  grep -nE '3000' src/server.js src/index.js → none
  Full test suite: 917/917 passing
  No existing test depended on 3000 as the port default (the only
  3000 references in test/ are millisecond timeouts; tests use
  getAvailablePort() for actual port binding).

Closes #477.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an inconsistency between the configured default port (4443 in src/config.js) and several runtime fallback paths that still defaulted to 3000. It centralizes the runtime fallback behavior by importing defaults and using defaults.port, ensuring future default-port changes only need to be made in one place.

Changes:

  • Import defaults from ./config.js and use defaults.port for options.port fallbacks in createServer() (single-user base URL and live reload watcher base URL).
  • Update startServer()’s default port parameter to defaults.port.
  • Update the package entry (src/index.js) to default to defaults.port when process.env.PORT is unset.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/server.js Replaces hard-coded 3000 fallbacks with defaults.port and updates startServer() default parameter.
src/index.js Aligns runtime default PORT fallback with defaults.port by importing canonical defaults.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@melvincarvalho
melvincarvalho merged commit ae78cc7 into gh-pages Jun 9, 2026
2 checks passed
@melvincarvalho
melvincarvalho deleted the issue-477-port-fallback-alignment branch June 9, 2026 19:23
melvincarvalho added a commit that referenced this pull request Jun 10, 2026
Bundles everything merged since 0.0.205 was published to npm
(2026-06-07):

- #539 fix(idp): handleSchnorrComplete recovers from
  interactionFinished throw — missing _interaction cookie now gets a
  clean 400 instead of a hung socket / gateway 504 (closes #412)
- #540 refactor(idp): sweep the hijack-then-throw defensive pattern
  across all 5 interaction handlers via a shared
  finishInteractionDefensively helper (foundation for #526)
- #542 fix: align runtime port fallbacks with the canonical 4443
  default — one source of truth in config.defaults (closes #477)
- #543 feat: configurable bodyLimit via createServer({ bodyLimit }),
  --body-limit, and JSS_BODY_LIMIT — large git pushes no longer 413
  at the hard-coded 10 MiB cap (closes #474)
- #546 fix(well-known-did-nostr): probe profile/card.jsonld for
  root-path WebIDs like https://melvin.solid.social/#me, with a
  cross-account guard on the subdomain fallback (closes #451)
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.

Follow-up to #245: align runtime port fallbacks in src/server.js with the 4443 config default

2 participants