andywer / andywer/threads.js

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'registerSerializer')

未关闭
#407 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
3.5k
派生
173
PR 合并指标
30 天内没有已合并 PR

描述

Hi everyone,
I have a problem with quasar framework and thread.js and I don't know how to solve the following error: **"Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'registerSerializer')"**

How reproduce this error:
`create quasar project` (with typescript support)
`npm install threads tiny-worker`
`npm install -D threads-plugin`

Then into your quasar.config.js:
`const ThreadsPlugin = require('threads-plugin');`

and extend webpack in build section:
`extendWebpack (cfg) {
cfg.plugins.push(new ThreadsPlugin())
}`

Finally tried the following code from thread.js documentation in typescript section:
```
//App.vue


import { spawn, Thread, Worker } from "threads"
import { Counter } from "./workers/counter"

export default {
setup(){
const counter = await spawn<Counter>(new Worker("./workers/counter"))
await counter.increment()
await Thread.terminate(counter)

return {}
}

```

```
//workers/counter.ts
import { expose } from "threads/worker"

let currentCount = 0

const counter = {
getCount() {
return currentCount
},
increment() {
return ++currentCount
},
decrement() {
return --currentCount
}
}

export type Counter = typeof counter

expose(counter)
```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。