feat: forward signal and onProgress to file.upload() so map imports can be cancelled
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- react, typescript
- Ambito
- api, mobile-dev
Direzione di ricerca
Inizia da contexts/MapServer.ts e segui uploadFile fino a useImportCustomMapFile. Verifica come il percorso File.upload di expo-file-system e il percorso api.put ricevono le opzioni, quindi determina come distinguere l'annullamento dai fallimenti effettivi. Il lavoro è completato quando signal e onProgress raggiungono entrambi i percorsi di upload e i chiamanti possono osservare l'avanzamento e interrompere l'operazione senza segnalare un errore normale.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
uploadFile in contexts/MapServer.ts forwards only httpMethod, headers and sessionType to file.upload():
const result = await file.upload(url, {
httpMethod: 'PUT',
headers: options.headers,
sessionType: 'foreground',
})
expo-file-system's UploadOptions also accepts signal (an AbortSignal) and onProgress, and neither is plumbed through uploadFile or useImportCustomMapFile. Compounding it, File.upload() is return new UploadTask(this, url, options).uploadAsync() — the UploadTask is constructed and immediately discarded, so no handle escapes either.
The practical consequence is that an in-flight map import cannot be cancelled from JS at all, and its progress cannot be observed. Unmounting the screen, navigating away, or reloading the JS runtime all leave the upload running.
Why this matters beyond ergonomics
An abandoned upload doesn't just waste bandwidth — it blocks every subsequent import. @comapeo/map-server serialises PUT /maps/:mapId on a per-mapId mutex and awaits request.body.pipeTo(...) inside the lock with no timeout (digidem/comapeo-map-server#64), so a still-running or stalled upload makes later attempts queue with no response until the client's own timeout fires.
In CoMapeo mobile that client is expo-file-system's uploader, whose OkHttp timeout is a fixed, non-configurable 60 s. A real Sentry event (COMAPEO-2MJ, Pixel 9, dev build) shows the shape:
17:51:52 touch "Choose File" <- attempt 1 starts
17:56:13 Navigation to Map <- user gives up after 4m21s and walks away;
attempt 1 keeps uploading, nothing cancels it
17:56:17 touch "Choose File" <- attempt 2, 4 seconds later
17:58:18 ERROR: Unable to upload a file: timeout
Attempt 1 never errored — it was still holding the mutex. Attempt 2 queued behind it and timed out. From the user's side this reads as "map import is broken", and it reproduces for any file size, which is what makes it confusing to diagnose.
Being able to abort on unmount would have released the lock when the user navigated away, and onProgress would have shown whether any bytes moved at all — the single most useful datum when one of these fails.
Proposed change
Accept signal and onProgress in uploadFile's options and forward them:
const result = await file.upload(url, {
httpMethod: 'PUT',
headers: options.headers,
sessionType: 'foreground',
signal: options.signal,
onProgress: options.onProgress,
})
and surface them on useImportCustomMapFile so callers can pass them per-mutation, e.g. mutate({ file, signal, onProgress }). An aborted upload should reject in a way callers can distinguish from a genuine failure, so it isn't reported as an error.
The non-isExpoFileWithUpload branch (api.put(path, { body: file, headers })) can take signal directly too, since fetch already accepts one — worth keeping the two paths consistent.
Happy to open a PR if this looks right.
- Lingua principale
- TypeScript
- Stelle
- 1
- Fork
- 1
- Merge medio
- 21m
- PR unite (30g)
- 4
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di digidem/comapeo-core-react
-
Add support for invite-over-internetForse già presa @achou11 l’ha presa 34 giorni fa. Aperta
digidem/comapeo-core-react#206 · 1 assegnatario ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
digidem/comapeo-core-react#195 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
digidem/comapeo-core-react#167 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
digidem/comapeo-core-react#135 ·
-
Expose Project Stats APIForse di nuovo libera @cimigree l’ha presa 414 giorni fa e non c’è nessuna pull request aperta. Aperta
digidem/comapeo-core-react#113 · 1 commento · 1 assegnatario ·
Tutte le issue di digidem/comapeo-core-react
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 2 giorni
-
reproduced
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
anomalyco/opencode#62052 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
strapi/design-system#2084 ·
I maintainer di solito rispondono entro 3 giorni
-
Report: &TV InternationalApertacheck:passed streams:remove
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
-
OAuth documentation for GET /api/v2/users/me/ appears inconsistent with required global read scopeAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno