Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Add AbortSignal cancellation support to IPFSStorage.upload and resolve

Aperta
#446 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Oothecae ci sta già lavorando.

Dal 16/10/2026.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
72/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
backend

Direzione di ricerca

Start in src/storage/ipfs.ts, where upload calls this.http.post and resolve loops over gateways with axios.get, then check how createApiHttpClient in src/utils/http.ts builds its config and how fetchWithTimeout in src/utils/timeout.ts already uses AbortSignal. Add an optional signal to both option interfaces and pass it into each request. Done means an already-aborted signal makes no network call, aborting mid-resolve skips the remaining gateways, and tests cover both cases.

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

Descrizione

difficulty: medium enhancement priority: medium sdk

Description

IPFSStorage.upload and IPFSStorage.resolve (src/storage/ipfs.ts) have no way for a caller to cancel an in-flight request. Checked on main:

  • upload(file, options) posts through this.http.post('', body, { headers: ... }) (createApiHttpClient from src/utils/http.ts) — no signal is ever read from options or forwarded into the axios request config.
  • resolve(cid, options) calls axios.get(url, { timeout, responseType: 'text', transformResponse: [...], validateStatus: ... }) per gateway in its fallback loop — again no signal.
  • IPFSUploadOptions and IPFSResolveOptions (the two option interfaces) have no signal/abortSignal field at all.

The SDK already uses AbortController/AbortSignal elsewhere (src/utils/timeout.ts's fetchWithTimeout, and the connection-pool work in src/utils/connection-pool.ts/src/node/agents.ts), so the pattern is established, but it was never threaded through to the storage module. In practice this means a consumer uploading a large file to IPFS, or resolving dispute-evidence JSON from a slow/unresponsive gateway, cannot cancel the call from a React component unmount, a user-initiated "cancel upload" action, or a request-level timeout budget shared with other work — the call can only ever finish or hit its own internal timeoutMs.

Component

SDK (src/storage/ipfs.ts)

Difficulty

🟡 Medium

Tasks

  • Add an optional signal?: AbortSignal field to IPFSUploadOptions and IPFSResolveOptions
  • Forward options.signal into the axios request config for upload's this.http.post(...) call
  • Forward options.signal (or a derived per-gateway signal) into each axios.get(...) call inside resolve's gateway loop, aborting the remaining fallback attempts once the caller's signal fires
  • Map an aborted request to a distinct, documented outcome ({ ok: false, error: 'Upload aborted' } for upload; a TrustFlowError code for resolve) rather than letting the raw AbortError/CanceledError propagate inconsistently
  • Add tests: aborting mid-upload resolves to the aborted result, aborting mid-resolve stops before trying the next fallback gateway

Acceptance Criteria

  • Passing an already-aborted AbortSignal to upload/resolve fails fast without making a network call
  • Aborting a resolve call part-way through the gateway fallback loop does not try subsequent gateways
  • Existing non-aborted call paths are unaffected

Estimated Time

3-4 hours

Lingua principale
TypeScript
Stelle
0
Fork
73
Merge medio
9h 18m
PR unite (30g)
58

Preparare l'ambiente

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 trustflow-protocol/trustflow-sdk

Tutte le issue di trustflow-protocol/trustflow-sdk

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.