threads.js: Tasks stuck and pool blocked

Hello, I’m having this weird behaviour where tasks are queued but the function itself is not running, and runningTasks just end up pilling up… Keep in mind that I have not changed anything in my code…

console.log('1')
		this[pool].queue(async worker => {
console.log('2')
			let m = worker[method]
console.log(m)
			if (!m) return "Method doesn't exist";
console.log('3')
			q = await m(item)
console.log('4')
			return q;
		})
console.log('5')
		await this[pool].completed()
console.log('6')
		return q;

and from the worker file:

const workerFunctions= {
    async gen(c) {
console.log('FUNCTION RUNNING')
..................
}
...........
}
expose(workerFunctions)

Behaviour: 1 2 [Function] 3 5

The thing is, the exposed function is not being executed at all (FUNCTION RUNNING is never logged) and the pool just ends up having more and more runningTasks pilling up…

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 18 (10 by maintainers)

Most upvoted comments

Any updates, @aya1337?

Hey @aya1337. Have you tried to enable debug logging?

https://threads.js.org/usage-advanced#debug-logging

I didn’t try debug logging, no idea how that went past my head Had to seperate the functions exposed into 3 types of pools and its now working just fine. I couldn’t wait because the service was down for so many people haha

I might try to check out the reason out when I have time, I’ll let you know if its anything serious Thank you!