Lazy load node:net for improved edge runtime compatibility

This commit is contained in:
2025-10-12 13:52:50 -04:00
parent 94a751d9b0
commit db96e8d933
7 changed files with 53 additions and 10 deletions
+14
View File
@@ -53,6 +53,20 @@ toRegistrableDomain("192.168.0.1"); // => null
- `isRegistered(domain, options?) => Promise<boolean>`
- `isAvailable(domain, options?) => Promise<boolean>`
### Edge runtimes (e.g., Vercel Edge)
WHOIS requires a raw TCP connection over port 43 via `node:net`, which is not available on edge runtimes. This package lazily loads `node:net` only when the WHOIS code path runs. To use rdapper safely on edge:
- Prefer RDAP only:
```ts
import { lookupDomain } from "rdapper";
const res = await lookupDomain("example.com", { rdapOnly: true });
```
- If `rdapOnly` is omitted and the code path reaches WHOIS on edge, rdapper throws a clear runtime error indicating WHOIS is unsupported on edge and to run in Node or set `rdapOnly: true`.
### Options
- `timeoutMs?: number` Total timeout budget per network operation (default `15000`).