vue-concurrency icon indicating copy to clipboard operation
vue-concurrency copied to clipboard

[Bug] regeneratorRuntime is not defined with useAsyncTask

Open dospunk opened this issue 3 years ago • 9 comments

I want to use useAsyncTask like so:

const myAsyncTask = useAsyncTask(() => {
    return functionThatReturnsPromiseWithMyData('this is an argument')
})

but when I try to run this, I get Uncaught (in promise) ReferenceError: regeneratorRuntime is not defined

I am using vue 3.1.4, vite 2.4.1, and vue-concurrency 2.1.2

dospunk avatar Jul 21 '21 17:07 dospunk

Strange. This should definitely not happen at least if the modern build is used where async await is not transpiled. I'll look into this tomorrow.

Dne st 21. 7. 2021 19:50 uživatel Connor Dooley @.***> napsal:

I want to use useAsyncTask like so:

const myAsyncTask = useAsyncTask(() => { return functionThatReturnsPromiseWithMyData('this is an argument')})

but when I try to run this, I get Uncaught (in promise) ReferenceError: regeneratorRuntime is not defined

I am using vue 3.1.4, vite 2.4.1, and vue-concurrency 2.1.2

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/MartinMalinda/vue-concurrency/issues/51, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACIHW6MIBZUWAIUZKCWEQHDTY4CFRANCNFSM5AYN3HJA .

MartinMalinda avatar Jul 21 '21 18:07 MartinMalinda

I'm getting this bug as well, with usePipeTask.

vite 2.1.3, vue 3.2.0, vue-concurrency 2.1.2

nickngqs avatar Aug 06 '21 05:08 nickngqs

same behavior with usePipeTask.

[email protected]
[email protected]
[email protected]

eLoyyyyy avatar Aug 20 '21 03:08 eLoyyyyy

Caused by https://github.com/developit/microbundle/issues/708. I tried to update microbundle but ran into different errors afterwards. I'll give it another try when I have more time.

MartinMalinda avatar Sep 23 '21 14:09 MartinMalinda

Any updates on this @MartinMalinda?

torleifhalseth avatar Mar 15 '22 15:03 torleifhalseth

I have this error too in a vue 3 project. I also tried pasting your example from the test as shown below and still have the same error:

const addTask = useTask(function* (signal, a: number, b: number) {
  return yield a + b;
});
const add10Task = useTask(function* (signal, a: number) {
  return yield a + 10;
});
const add20Task = useTask(function* (signal, a: number) {
  return yield a + 20;
});
const pipeTask = useSequentialTask(addTask, add10Task, add20Task);

When i remove the last line, I get no errors. This makes the library unfortunately unusable for me.

amrap030 avatar Apr 19 '22 16:04 amrap030

With Vue 3 & Vite I've been using the temporary fix of :

  1. npm install regenerator-runtime
  2. Adding import 'regenerator-runtime/runtime' at the top of main.ts

If you're using webpack/babel (ie Vue 2), you can also import it directly without the extra package: import '@babel/runtime/regenerator';

Hawxy avatar Jun 29 '22 11:06 Hawxy

Since vite is used to bundle the lib now, there's a good chance it's fixed in 5.0. Can anyone confirm?

MartinMalinda avatar Feb 06 '24 14:02 MartinMalinda

Yes this is fixed.

Hawxy avatar Feb 07 '24 01:02 Hawxy