Skip to content

out of band cancellation #2

Closed
Closed
@bmeck

Description

@bmeck

This is a very important note in allowing resource guards. Out of band cancellation allows for resources to affect the cancellation of a task. I have talked about this some in: tc39/proposal-async-await#27 . However, I will rephrase it here. The easiest example is lock files; given the following:

async function () {
  try {
    let lock = await getLock(__filename);
    lock.oncompromised = cancel;
    // tasks requiring the lock
  }
  finally {
    // cleanup
  }
}

It is important to allow the lock to cancel any tasks requiring it. By cancel I do not mean to rollback, but rather to stop execution of the next task and instead attempt to return (not throw). The alternative is to force every await to have a programmatic guard which is more error prone and requires knowledge of how to check if a resource is compromised.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions