synapse-sdk: StoreError buries the root cause under repeated wrapper messages

Aperta
#1,195 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Start with packages/synapse-sdk/src/storage/context.ts at StorageContext.store() and packages/synapse-sdk/src/storage/manager.ts where StoreError is built; then read the SynapseError cause handling in packages/synapse-core/src/errors/base.ts. Check the existing message assertions in storage.test.ts and synapse.test.ts. Done means StoreError names the provider once and presents the deepest typed error’s short message and details without repeating wrapper messages.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Follow-up to #841. #1175 makes synapse-core throw InvalidUploadSizeError instead of NetworkError. The SDK still wraps that error twice, and each wrapper copies in the full message of the error directly below it. A consumer such as filecoin-pin that shows StoreError.message gets the real cause, but buried and repeated:

Failed to store piece on service provider 2 (https://calib2.ezpdpz.net)

Details: StorageContext store failed: Failed to store piece on service provider - Invalid upload size.

Details: Size 125 bytes is below minimum allowed size of 127 bytes or exceeds maximum ...

(This output is worked out from the code, not captured from a run.)

Where it comes from
  1. StorageContext.store() wraps the core error with createError(). That gives a plain Error whose message is StorageContext store failed: Failed to store piece on service provider - <the core error's full message>.
  2. StorageManager wraps that in a StoreError with the same "Failed to store piece on service provider" text.
  3. SynapseError fills in details from cause.message when no details are given. That copies the whole message from step 1, including the core error's own Details: line.

The typed error is still there at error.cause.cause, so code can find it. Only the message is hard to read.

Expected

The StoreError message names the provider once and shows the deepest SynapseError's shortMessage and details:

Failed to store piece on service provider 2 (https://calib2.ezpdpz.net)

Details: Invalid upload size. Size 125 bytes is below minimum allowed size of 127 bytes ...
Possible fixes

These are #841's suggestions 2 and 3:

  • In StorageContext.store(), rethrow a SynapseError from core unchanged, or wrap it in a typed error that passes on its details, instead of using createError().
  • When building StoreError details, look down the cause chain for the deepest SynapseError and use its shortMessage and details, not the message of the error directly below.

Existing tests check the message for 'Failed to store piece on service provider' (storage.test.ts, synapse.test.ts). They should keep passing, or be updated deliberately.

Lingua principale
TypeScript
Stelle
27
Fork
36
Merge medio
2g 4h
PR unite (30g)
65

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di FilOzone/synapse-sdk

Tutte le issue di FilOzone/synapse-sdk

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.