(error: unknown)
| 231 | |
| 232 | /** True when an error (or any nested cause) is an EADDRINUSE bind failure. */ |
| 233 | export const isAddrInUse = (error: unknown): boolean => { |
| 234 | for (let cursor: unknown = error; cursor instanceof Error; cursor = cursor.cause) { |
| 235 | if ((cursor as NodeJS.ErrnoException).code === "EADDRINUSE") return true; |
| 236 | // The emulate/vite boot glue wraps the OS error in a plain Error whose |
| 237 | // message carries the code, so match the text too. |
| 238 | if (/EADDRINUSE/.test(cursor.message)) return true; |
| 239 | } |
| 240 | return false; |
| 241 | }; |
| 242 | |
| 243 | /** |
| 244 | * Claim a port block and boot the services that bind it, retrying on EADDRINUSE. |
no outgoing calls
no test coverage detected