rspack: --port with a host prefix yields RSPACK_DEVSERVER_PORT=NaN and kills the client compilation
Summary
meteor run --port <host>:<port> makes the rspack integration compute RSPACK_DEVSERVER_PORT=NaN, and the client compilation dies before its first build with ERR_SOCKET_BAD_PORT.
--port is documented as accepting [host:]port, so this affects every app that binds an explicit host — a very common setup for tunnelled/remote development and for running several apps side by side.
Cause
calculateDevServerPort() assumes the value returned by getMeteorAppPort() is digits only:
export function calculateDevServerPort() {
const port = getMeteorAppPort();
const basePort = 8077;
// Sum the digits of the port
const digitSum = port.split('').reduce((sum, digit) => sum + parseInt(digit, 10), 0);
return basePort + digitSum;
}
but getMeteorAppPort() returns the raw --port option, host prefix included:
export function getMeteorAppPort() {
return Package?.meteor?.global?.currentCommand?.options?.['port'] || process.env.PORT || '3000';
}
With --port localhost:3060, parseInt('l', 10) is NaN, the sum is NaN, and 8077 + NaN is NaN. That value is then stringified into the environment of the spawned rspack process, so devServer.port ends up NaN.
Reproduction
Any rspack-enabled app on [email protected] with [email protected] / @meteorjs/[email protected]:
meteor run --port localhost:3060
=> Started MongoDB.
[rspack-cli] RangeError [ERR_SOCKET_BAD_PORT]: options.port should be >= 0 and < 65536. Received type number (NaN).
at Server.listen (node:net:2159:5)
at READ_WRITE (…/node_modules/webpack-dev-server/lib/Server.js:3460:23)
at RspackDevServer.start (…/node_modules/webpack-dev-server/lib/Server.js:3458:7)
code: 'ERR_SOCKET_BAD_PORT'
Rspack plugin error: Rspack client process exited unexpectedly (code 2) before completing its first compilation.
meteor run --port 3060 (no host) works. [::]:3005, used by meteor test setups, fails the same way.
Expected
The dev-server port should be derived from the port component only, e.g. parse the [host:]port form before summing digits, or reuse whatever the tool already uses to split --port into host and port.
Workaround
Set RSPACK_DEVSERVER_PORT explicitly:
RSPACK_DEVSERVER_PORT=8060 meteor run --port localhost:3060
Side note
The digit-sum heuristic also collides readily even when it does work — 3010, 3100, 3001 and 1300 all map to 8081 — so apps started on different ports can still fight over one dev-server port.
Versions
- Meteor
[email protected] [email protected](Atmosphere),@meteorjs/[email protected],@rspack/core/@rspack/cli1.7.11- macOS 26.6.2 (arm64), Node 24 (bundled with the Meteor tool)
Source: meteor/meteor