fix: align runtime port fallbacks with canonical 4443 default — closes #477#542
Merged
Merged
Conversation
#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.
There was a problem hiding this comment.
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
defaultsfrom./config.jsand usedefaults.portforoptions.portfallbacks increateServer()(single-user base URL and live reload watcher base URL). - Update
startServer()’s defaultportparameter todefaults.port. - Update the package entry (
src/index.js) to default todefaults.portwhenprocess.env.PORTis 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
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #477.
Bug
#245 changed the declared default port from 3000 → 4443 in
src/config.js(April 2026), but four runtime fallbacks still readport || 3000. Programmatic embedders, tests that calledstartServer()with no port, and the package'smainentry (src/index.jswhenPORTenv 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 atsrc/index.js:3and is included.Fix
Uses the author's preferred "one source of truth" shape from the issue body — import
defaultsfrom./config.jsand referencedefaults.portso future port changes only touch one file.src/server.js:879options.port || 3000options.port || defaults.portsrc/server.js:1224options.port || 3000options.port || defaults.portsrc/server.js:1235startServer(port = 3000, ...)startServer(port = defaults.port, ...)src/index.js:3process.env.PORT || 3000process.env.PORT || defaults.portPlus 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 instartServer's signature andsrc/index.jsare 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→ nonenode --checkon both files → OK3000references intest/are millisecond timeouts; actual port binding goes throughgetAvailablePort()Refs