Problem
faker.internet.port() returns integers in [0, 65535], but port 0 is reserved (RFC 6335 §6, IANA) and must not appear on the wire. Test code that feeds the value into a real socket (net.connect({ port: 0 }), new URL(...)) gets OS-assigned ephemeral behavior instead of the seeded value, producing non-deterministic tests.
Steps
import { faker } from '@faker-js/faker'; // 10.5.0
faker.seed(1);
for (let i = 0; i < 100000; i++) {
if (faker.internet.port() === 0) { console.log('got 0 at', i); break; }
}
Expected
A port in the valid usable range [1, 65535] (or a documented option to include 0).
Actual
0 is returned. Source: src/modules/internet/module.ts:727 — return this.faker.number.int(65535); which inclusively includes 0. The existing test at test/modules/internet.spec.ts:733 also asserts toBeGreaterThanOrEqual(0), codifying the defect.
Environment
@faker-js/faker 10.5.0 (next branch, commit on 2026-07-03)
- Node 20+
Thanks for maintaining faker-js/faker!
Problem
faker.internet.port()returns integers in[0, 65535], but port0is reserved (RFC 6335 §6, IANA) and must not appear on the wire. Test code that feeds the value into a real socket (net.connect({ port: 0 }),new URL(...)) gets OS-assigned ephemeral behavior instead of the seeded value, producing non-deterministic tests.Steps
Expected
A port in the valid usable range
[1, 65535](or a documented option to include 0).Actual
0is returned. Source:src/modules/internet/module.ts:727—return this.faker.number.int(65535);which inclusively includes 0. The existing test attest/modules/internet.spec.ts:733also assertstoBeGreaterThanOrEqual(0), codifying the defect.Environment
@faker-js/faker10.5.0 (next branch, commit on 2026-07-03)Thanks for maintaining faker-js/faker!