Closed legraphista closed 7 years ago
Similar problem demonstrated by the following test case in test-package.js
:
tap.test('eval pool with callback that throws', function(t) {
var tcount = 0;
function test() {
console.log('test function in thread pool');
}
var mypool = Threads.createPool(5);
//mypool.all.eval(test);
mypool.all.eval('test()', function(err, data) {
++tcount;
if (tcount === 2)
throw new Error('boom');
if (tcount == 5) {
mypool.destroy();
t.end();
}
});
});
The following change (with JavaScript code regenerated by npm run js
) seems to fix the problem with the original code but not in the test case above:
diff --git a/src/createPool.ls b/src/createPool.ls
index f12894b..f464560 100644
--- a/src/createPool.ls
+++ b/src/createPool.ls
@@ -41,7 +41,10 @@ function create-pool (n)
next-job t
f = job.cb-or-data
if typeof f is \function
- f.call t, e, d
+ try
+ f.call t, e, d
+ catch e
+ return e
else
t.emit job.src-text-or-event-type, f
else if job.type is 2 # EMIT
Going to sleep now, hope to give it a try when I am up again.
Any progress on this? Running into the exact same error. Node: 6.9.2 OS: Debian GNU/Linux 8 (jessie)
Fixed in webworker-threads-0.7.10. Thanks for the reminder!
Thank you, will test later.
@audreyt I must be missing something here. What does 0d9a167 actually accomplish? I see it must be important, since you added it again in 1a3fbed2 after I removed it in #141. But with RAII, what is the effect of creating a Locker within the scope of an otherwise empty if statement?
@brodybits I don't see that test case in test-package.js. Since I appear to have inadvertently re-introduced this bug until @audreyt fixed it in 1a3fbed, perhaps adding it to the test suite would be helpful?
Hi, Working with the following code:
I can consistently reproduce the following error:
Node: 4.5.0, 6.3.1, 6.5.0 OS: OSX 10.11.6
EDIT 1: The issue was caused due to an error in the callback,
err
isnull
(silly me), so it would throw when accessingerr.stack
I think this is still an issue because the error in the callback did not bubble up and did not appear, even withprocess.on('uncaughtException', (err)=>console.error(err))
present.