Closed nodehack closed 5 years ago
Which version of microjob are you using?
I tried that code, compiled with tsc and used with Node.js 10.5 with --experimental-worker flag and it worked.
I'm using: microjob 0.5.2. Node 12.1.0 with no --experimental-worker flag. It was removed from the docs and this article indicates it is no longer needed: https://wanago.io/2019/05/06/node-js-typescript-12-worker-threads/
I switch my node version to 10.15.3 and added the flag and still have the same issue. Wondering if this is caused by ts-node which I use when developing. What command are you using to run the code?
Hmm...looks like the same thing when running using just node.
node --experimental-worker server.js
{
"name": "default-app-name",
"hostname": "something.local",
"pid": 18637,
"level": 50,
"err": {
"message": "__awaiter is not defined",
"name": "Error",
"stack": "ReferenceError: __awaiter is not defined\n at eval (eval at parentPort.on (thingy/node_modules/microjob/dist/worker.js:10:5), <anonymous>:8:29)\n at __executor__ (eval at parentPort.on (thingy/node_modules/microjob/dist/worker.js:10:5), <anonymous>:18:16)\n at MessagePort.parentPort.on (thingy/node_modules/microjob/dist/worker.js:12:27)\n at MessagePort.emit (events.js:189:13)\n at MessagePort.onmessage (internal/worker.js:84:8)"
},
"msg": "Unhandled promise rejection occurred.",
"time": "2019-05-08T14:43:09.184Z",
"v": 0
}
Here is my tsconfig:
{
"include": [
"./src/**/*.ts"
],
"exclude": [
".tmp",
"dist",
"public",
"node_modules"
],
"compileOnSave": false,
"compilerOptions": {
"noEmitHelpers": false,
"allowJs": true,
"esModuleInterop": true,
"target": "ES2015",
"module": "commonjs",
"moduleResolution": "Node",
"alwaysStrict": true,
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"outDir": "dist",
"lib": [
"es2017",
"dom",
"esnext"
],
"typeRoots": [
"node_modules/@types",
"types"
]
}
}
Found it! It was a tsconfig issue. Looks like you must have your target set to es2017.
I removed lib
from the compilerOptions and set target to es2017
. Works!
Synchronous jobs run fine but I'm getting this error when trying to run an async job:
Example code:
Any ideas?