Skip to content

Error handling: getKeysFromRelayer wraps all errors as 'wrong relayer url' #379

@gustavovalverde

Description

@gustavovalverde

Summary

The SDK wraps all errors in getKeysFromRelayer (network, JSON, deserialization, etc.) as:

"Impossible to fetch public key: wrong relayer url."

This is misleading and hides the true root cause for callers. In real-world usage, the error often has nothing to do with the relayer URL.

Where

src/relayer/network.ts (or equivalent in build output)

Current behavior (simplified):

try {
  // fetch key url, fetch public key, fetch CRS, deserialize
} catch (e) {
  throw new Error('Impossible to fetch public key: wrong relayer url.', { cause: e })
}

Why this is a problem

  • Misleads SDK users (sends them debugging the URL when the issue is deserialization, bytes type mismatch, IO errors, etc.)
  • Many environments don’t surface cause, so the actual error is lost.

Suggested improvements

  • Use a neutral message like:
    • Failed to fetch or deserialize public key
  • Or differentiate between error classes:
    • network failure vs JSON parsing vs deserialization vs invalid URL
  • Surface original message even when wrapped.

Example change

throw new Error('Failed to fetch or deserialize public key', { cause: e });

Optional: include an error code or custom error type so SDK users can handle it programmatically.

Happy to provide a PR if desired.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions