When you serialize/dehydrate async results (queries, promises, RSC/RPC payloads), treat error objects as sensitive and do not transport raw server error details to the client/shared layer. Use a default redaction policy and make the behavior explicitly configurable and documented.

Apply this rule:

Example pattern:

function shouldRedactError(error: unknown): boolean {
  // default: redact to prevent leaking server-side details
  return true
}

function dehydratePromise(promise: Promise<unknown>) {
  return promise.catch((error) => {
    if (shouldRedactError(error)) throw new Error('redacted')
    throw error
  })
}