Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

TaskEx: AwaitTaskCorrect / Task.toAsync / Async.ofTask

Abierto
#141 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Tranquilo
Stack tecnológico
fsharp
Área
backend

Línea de trabajo

Comienza leyendo las APIs propuestas, las issues sustituidas 129 y 139 y el fslang-suggestion enlazado. Compara las copias canónicas de la implementación en Equinox, Propulsion y FSharp.AWS.DynamoDB. Se considerará terminado cuando exista una API acordada y una semántica de cancelación y excepciones adecuada para una implementación compartida.

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

Descripción

feature request topic: task-ex

Replaces https://github.com/fsprojects/FSharp.Control.TaskSeq/issues/129. TaskEx top level issue: https://github.com/fsprojects/FSharp.Control.TaskSeq/issues/139

The default implementation of the Async.AwaitTask methods in FSharp.Core have some key shortcomings:

  1. when the Task faults, yielding an exception, that exception is typically (always?) wrapped in an egregious AggregateException
  2. the default implementation does not abort/cancel when the ambient CancellationToken of the async expr within which Async.AwaitTask is triggered
  3. cancelling an Async computation should not just abort the processing, it should also propagate a TaskCancelledException to align with the behavior of Task

While it can be argued that the current behavior is 'wrong', it's also obvious that breaking it would be untenable, and the semantic differences are beyond what one might cover with subtle overloads and/or adding optional arguments etc.

Current proposed APIs (will be updated inline based on any discussion below):

module Async =
    let inline ofTask (t : Task<'t>) : Async<'t> = AwaitTaskCorrect t
    let inline ofUnitTask (t : Task) : Async<'t> = AwaitTaskCorrect t
module Task =
    let inline toAsync (t : Task<'t>) : Async<'t> = Async.ofTask t

NOTES:

  • the above naming is taken from the helpers within TaskSeq, which are exposed in the FSharp.Control namespace. NOTE the current implementations use Async.AwaitTask, but that was not as a conscious choice, and there is a desire` to fix at least some of the shortcomings noted
  • given the fact that task and async are now first class citizens of FSharp.Core, having an of/to pairing would seem to make sense. This is open to debate; not sure the degree to which the prior art is consistent wrt this beyond collection types/modules
  • There is an fslang-suggestion regarding this. The purpose of this issue is as a placeholder for potentially filling the gap until this issue can be more thoroughly resolved in FSharp.Core proper.
  • Equinox, Propulsion and FSharp.AWS.DynamoDB all have copies of the canonical impl in Eirik's fssnip. Not ruling out tweaks to the semantics, but ideally those libraries, and others, would all share the same semantics
  • if this is handled as a module, one also frequently needs an ofUnitTask alongside as above (Async.AwaitTask is a pair of overloaded methods, which often brings its own issues with intellisense and error messages etc)
Lenguaje dominante
F#
Estrellas
111
Forks
13
Merge medio
7 h 59 min
PR fusionados (30 d)
3

Guía de contribución

Abrir la guía de contribución

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 fsprojects/FSharp.Control.TaskSeq

Todos los issues de fsprojects/FSharp.Control.TaskSeq

Issues similares

Más issues de Backend & API Design

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.