From: aardizio Date: Wed, 22 Jan 2020 19:01:28 +0000 (+0100) Subject: Fix problem in node 13.x version X-Git-Tag: v0.0.1~5 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=8950a9413daaff104bdfe23de5331ff744ee883b;p=poolifier.git Fix problem in node 13.x version --- diff --git a/lib/workers.js b/lib/workers.js index 0e8569e5..103061aa 100644 --- a/lib/workers.js +++ b/lib/workers.js @@ -27,7 +27,7 @@ class ThreadWorker extends AsyncResource { if (value && value.data && value._id) { // here you will receive messages // console.log('This is the main thread ' + isMainThread) - this._run(fn, value) + this.runInAsyncScope(this._run.bind(this), this, fn, value) } else if (value.parent) { // save the port to communicate with the main thread // this will be received once @@ -48,7 +48,7 @@ class ThreadWorker extends AsyncResource { _run (fn, value) { try { - const res = this.runInAsyncScope(fn, null, value.data) + const res = fn(value.data) this.parent.postMessage({ data: res, _id: value._id }) this.lastTask = Date.now() } catch (e) { diff --git a/package.json b/package.json index f8e74782..dbf9425d 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "build": "npm install", "test": "standard && nyc mocha --exit --timeout 20000 tests/*test.js ", - "debug-test": "mocha --inspect-brk --experimental-worker --exit tests/*test.js ", + "debug-test": "mocha --inspect-brk --exit tests/*test.js ", "demontest": "nodemon --exec \"npm test\"", "coverage": "nyc report --reporter=text-lcov tests/*test.js | coveralls", "standard-verbose": "npx standard --verbose",