Skip to content

Conversation

@lidel
Copy link
Member

@lidel lidel commented Dec 18, 2025

this fixes sporadic "invalid ip address" errors on Windows (and occasionally macOS) caused by a V8 JIT optimization bug corrupting complex regex patterns.

the old multiaddr package used is-ip which relies on a 1,150-character IPv6 regex from ip-regex. under certain conditions, V8's JIT compiler would incorrectly optimize this regex, causing valid IPs like "127.0.0.1" to fail validation.

the fix migrates from deprecated packages to their maintained successors:

  • ipfs-http-client -> kubo-rpc-client
  • ipfsd-ctl@10 -> ipfsd-ctl@16
  • multiaddr -> @multiformats/multiaddr@13
  • multiaddr-to-uri -> @multiformats/multiaddr-to-uri

the new @multiformats/multiaddr uses @chainsafe/is-ip which validates IPs with a parser-based approach instead of regex, eliminating the bug.

the migration also restores proper daemon output monitoring for migration progress detection by accessing ipfsd-ctl's subprocess streams directly, with runtime checks that log warnings if internals change in future versions.

closes #2329

TODO

since the new packages are ESM-only and ipfs-desktop uses CommonJS, this adds src/esm-loader.js to handle dynamic imports at startup.

@lidel lidel force-pushed the fix/kubo-rpc-client-migration branch 2 times, most recently from 6bc019a to 0b7cc30 Compare December 18, 2025 06:25
- migrate from ipfs-http-client to kubo-rpc-client
- migrate from ipfsd-ctl v10 to v16
- bundle ESM-only deps to CJS via esbuild (fixes Electron compatibility)
- fix multiaddr API: replace deprecated nodeAddress() with getComponents()
- fix ipfsd-ctl v16 API: use init/start: false, call manually
- fix repo path defaulting to ~/.ipfs when empty
@lidel lidel force-pushed the fix/kubo-rpc-client-migration branch from 0b7cc30 to ae22d72 Compare December 18, 2025 06:38
@lidel lidel self-assigned this Dec 18, 2025
the macOS universal binary build was failing with "pattern is too long"
from minimatch during ASAR merge. the ESM packages and their transitive
deps had long file paths exceeding minimatch's limit.

since these packages are bundled into esm-bundle.cjs at build time,
they don't need to be in runtime dependencies. moving them to
devDependencies reduces the packaged node_modules from 1237 to 1130
packages.

also inlines p-defer (was a transitive dep) to avoid adding a new
runtime dependency.
@lidel lidel force-pushed the fix/kubo-rpc-client-migration branch from 8bb79a7 to 0172ea8 Compare December 18, 2025 07:08
e2e tests that start external daemons via `makeRepository({ start: true })`
must stop them before the Electron app closes. On Windows, leaving an
external daemon running while calling `app.close()` can cause Playwright
to hang because the app maintains an RPC connection to the daemon.

added try/finally blocks with fallback to RPC shutdown if stop() fails.
detect whether we spawned the daemon or connected to an external one
by checking if `$IPFS_PATH/api` exists before starting:
- api existed → external daemon, just disconnect on quit
- api didn't exist → we spawned it, wait for graceful shutdown

also handle stale api file case: if connection fails and we have
config, remove api file and retry - mark as our daemon.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[gui error report] Error: invalid ip address

2 participants