We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I would like to implement a task modifier that, when added to a task, will make it throw an error if it takes too long.
It would be used like this:
myTask = task({timeout: 3000}, async () => { await someAsyncStuff })
and if someAsyncStuff doesn't resolve or reject within the specified time it will throw a timeout error
someAsyncStuff
timeout
This is what I've tried, but it doesn't seem to work.
import {race, rawTimeout} from 'ember-concurrency'; export default function timeout(taskFactory, time) { const taskDefinition = taskFactory.taskDefinition; const timer = async () => { await rawTimeout(time); throw new Error(timeout); }; const timeoutTaskDefinition = function* (...args) { yield* race([ taskDefinition.call(this, ...args), timer() ]); }; taskFactory.setTaskDefinition(timeoutTaskDefinition); } // initializer import {registerModifier} from 'ember-concurrency'; import timeoutTaskModifer from 'frontend/task-modifiers/timeout'; registerModifier('timeout', timeoutTaskModifer);
It throws this error when starting the task
Uncaught TypeError: yield* (intermediate value) is not iterable
Any help would be appreciated.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I would like to implement a task modifier that, when added to a task, will make it throw an error if it takes too long.
It would be used like this:
and if
someAsyncStuff
doesn't resolve or reject within the specified time it will throw atimeout
errorThis is what I've tried, but it doesn't seem to work.
It throws this error when starting the task
Uncaught TypeError: yield* (intermediate value) is not iterable
Any help would be appreciated.
The text was updated successfully, but these errors were encountered: