Skip to content

Follow arrays of delivery promises returned by local helpers in outbox-listener-delivery-not-awaited #1070

Description

@dahlia

Why

outbox-listener-delivery-not-awaited, added in #1067 for #1057, tracks two shapes of value: a delivery promise, and an array of delivery promises such as the result of map(). An array waits for nothing on its own, so the rule reports it when it reaches an await, a return from the listener, or an expression statement, and accepts it once it reaches Promise.all() or one of its siblings.

A local helper that returns such an array is left alone, though. This was a deliberate trade-off in #1067: the rule does not follow the returned array to the helper's call sites, so it cannot tell the good shape from the bad ones. Treating the return inside the helper as a drop would report the common, correct shape:

const deliverAll = () =>
  inboxes.map((inbox) => ctx.sendActivity(sender, inbox, activity));
await Promise.all(deliverAll());

Leaving it alone means these are not reported, although nothing waits for any delivery:

const deliverAll = () =>
  inboxes.map((inbox) => ctx.sendActivity(sender, inbox, activity));
await deliverAll();
deliverAll();

const deliver = () => [ctx.sendActivity(sender, inbox, activity)];
deliver();

Scope

Follow the shape a local helper returns to each place it is called, the same way the rule already follows a helper that returns a single promise. A call to a helper that returns an array of promises should be judged as an array: handled when it reaches Promise.all() or one of its siblings, or a variable that is mentioned again, and reported when it is awaited, returned from the listener, or dropped.

A helper that returns an array along one path and a promise along another, or whose return value the rule cannot classify, should keep the rule quiet, as it does today for anything it cannot follow.

Non-goals

Helpers declared outside the listener or in another module stay out of scope, the same boundary as #1054. No type information.

Suggested checks

Cover each shape above: the helper passed to Promise.all() (not reported), awaited directly, called as a bare statement, and a helper returning an array literal. Add a helper that returns an array which is kept in a variable and passed to Promise.all() later, and one that returns an array to another local helper which awaits it with Promise.all(). Update the limitations listed for the rule in docs/manual/lint.md if the manual mentions this gap by then.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions