Add "cancellation" support - AbortSignal
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 45
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
Almost all the methods are async. However, there is no way to cancel these async tasks.
What if we extend InteractionOptions with an AbortSignal ?
export interface InteractionOptions {
signal?: AbortSignal,
formIndex?: number;
uriVariables?: object;
data?: any;
}
For example, we could imagine:
// client
function run(thing: ConsomedThing) {
const controller = new AbortController();
// after 1000ms we abort the promise
const timer = setTimeout(() => {
controller.abort('timeout');
}, 1000);
// read the value
return thing.readProperty('state', { signal })
.then((output: InteractionOutput): Promise<DataSchemaValue> => {
return output.value({ signal });
})
.finally(() => {
clearTimeout(timer);
});
}
Minimal scenario: the ConsumedThing aborts any async tasks related to this readProperty call (ex: aborts a fetch) and returns a rejected Promise (with an AbortError if we accept DOMErrors).
Extended scenario (optional): same as minimal scenario, but we may send an "abort" request too. In this case we may think about:
// server
function run(thing: ExposedThing) {
thing.setPropertyReadHandler('state', ({ signal }) => {
return fetch('https:///another-api.com', { signal });
});
}
The client send an "abort" request for a specific property (ex: /property-name/abort/), or maybe if the server detects that the connection was terminated before he was able to send the property's value. In this case, the received signal in setPropertyReadHandler is aborted.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating InteractionOptions and the ConsumedThing asynchronous operations described in the issue. Trace how readProperty and InteractionOutput.value propagate options, then determine the minimal cancellation behavior and how an aborted task should reject. Done means the proposed AbortSignal behavior is defined for the minimal scenario; the optional server-side abort flow remains a separate design question.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100