Crash on iOS when re-using background URLSession identifier

Abierto
#229 0 comentarios 0 reacciones 0 asignados Ver en GitHub

@samsonjs ya está trabajando en esto.

Desde el 21/10/2026.

  • #234 de @samsonjs — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
swift

Línea de trabajo

The affected entry point is TUSClient.deinit; inspect how the URLSession configuration identifier distinguishes background from foreground sessions. Reproduce the reuse case with a background identifier and verify that deinitialization no longer invalidates that session while foreground sessions still finish and invalidate their tasks.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

TUSClient.deinit finishes and invalidates the session even when it's a background session. In my app I was re-using the same session ID after changing service environments (prod/staging/dev) and that causes this crash:

BackgroundSession <5B232D47-B8F1-4848-9A69-8196786E5921> attempted to create a NSURLSessionDataTask in a session that has been invalidated
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Task created in a session that has been invalidated'
*** First throw call stack:
(0x18ce25044 0x18a2bdabc 0x18e51c780 0x18e31997c 0x18e31607c 0x103cb2064 0x103ca919c 0x18e3170c4 0x18e31932c 0x1106bd630 0x1106dd500 0x1106b4944 0x103c98584 0x103cb2064 0x103ca091c 0x103ca15a4 0x103cad894 0x103caceb0 0x21720ca0c 0x21720caac)
libc++abi: terminating due to uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Task created in a session that has been invalidated'
*** First throw call stack:
(0x18ce25044 0x18a2bdabc 0x18e51c780 0x18e31997c 0x18e31607c 0x103cb2064 0x103ca919c 0x18e3170c4 0x18e31932c 0x1106bd630 0x1106dd500 0x1106b4944 0x103c98584 0x103cb2064 0x103ca091c 0x103ca15a4 0x103cad894 0x103caceb0 0x21720ca0c 0x21720caac)
terminating due to uncaught exception of type NSException

Should TUSClient.deinit only finish and invalidate tasks when it's a foreground session and its configuration identifier is nil? That fixes the issue here and I think it's correct, but wanted to talk it over before opening up a PR.

Lenguaje dominante
Swift
Estrellas
245
Forks
129
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de tus/TUSKit

Todos los issues de tus/TUSKit

Issues similares

Más issues de Swift

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.