-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Error and leaks on immediate resolved/returned data and thrown errors #49
Comments
Deno is not able to properly track ressource leaks when web worker are used and must be disabled in its testing framework to avoid false positive. If the issues are reproducible without any testing framework and with a kind of bare metal deno implementation, it worth investigating. |
Ok. You say, the timer leak messages can be securely ignored? bdd is the Deno std library behavior driven testing, so still Deno standard. |
I reduced it to Deno.test, which makes no difference. import { availableParallelism, DynamicThreadPool, PoolEvents } from '@poolifier/poolifier-web-worker';
import type { WorkerData, WorkerResponse } from '.../worker-error.ts';
Deno.test('Worker', async () => {
const workerFileURL = new URL('.../worker-error.ts', import.meta.url);
const threadPool = new DynamicThreadPool<WorkerData, WorkerResponse>(
1,
availableParallelism(),
workerFileURL,
{
enableTasksQueue: true,
tasksQueueOptions: {
concurrency: 1,
size: 1,
taskStealing: true,
tasksStealingOnBackPressure: false,
}
}
);
threadPool.eventTarget?.addEventListener(PoolEvents.taskError, (err) => { console.error(err); });
threadPool.eventTarget?.addEventListener(PoolEvents.messageerror, (err) => { console.error(err); });
threadPool.eventTarget?.addEventListener(PoolEvents.error, (err) => { console.error(err); });
const taskSpawn = (n: number) => threadPool.execute({ n: n }, 'something');
const tasks: Promise<void>[] = [];
for (let i = 0; i < 10; i++) {
const task = taskSpawn(i)
.then((response: WorkerResponse) => {
console.info('worker response: ', response);
}).catch((err) => {
console.error('task error: ', err);
});
tasks.push(task);
}
console.info(`added ${tasks.length} tasks`);
await Promise.allSettled(tasks);
await threadPool.destroy();
}); |
The error worker side is propagated to the main thread in the response (and an event if event emission is enabled) and the worker is not crashed (no error propagation in the worker). It's the intended behavior.
And: "Deno is not able to properly track ressource leaks when web worker are used and must be disabled in its testing framework to avoid false positive". Look at the code in tests/, resources leaks detection is often disabled because of false positive. |
|
Thank you, I'm not sure what you mean with execute-response handler. I don't use try/catch, but catch on the returned Promise from execute. Is this not already what you mean? And I still don't understand the correlation for case 4., where I throw an error in the worker, which results in a TypeError within DynamicThreadPool.afterTaskExecutionHook:
This error seems completely unrelated to my manually thrown error, which I'm not sure how to properly handle. |
Avoid testing by using an indirection layer like a unit tests framework: it uses native OS thread for unit tests (in Deno), ... The number of indirection layers introduced will not make the debugging close to the real world usage.
I missed that one in the report. It looks genuine since in case of task error |
Please reopen if not fixed in 0.4.15 release. |
Thank you very much for your swift response and fix. Errors are gone. |
Duplicate issue
Description
The library seems a good fit and I tried my luck with some small/minimal examples triggered by a Deno test case.
I get some errors for these "artificial" test cases. One about an undefined property and in some cases there are timer leaks.
Would be happy if you gave it a look. Maybe I made a mistake or it's secure to ignore these errors for non-artificial cases. I'm also a bit new to Deno. Thanks.
This is my
worker-error.ts
:... run with the
--trace-leaks
flag.with import-map in deno.jsonc:
The worker:
Now I have some cases with the
something
method:Produces timer leaks.
Terminal Output
This is ok and produces no errors.
Terminal Output
But without a delay it does have leaks.
Terminal Output
Throwing an error is propagated to the taskError event handler, but not catched by the
taskSpawn().catch
, is this normal?Maybe it's prevented by the TypeError thrown in
DynamicThreadPool
(see log).Terminal Output
Expected behavior
No response
Actual behavior
No response
Steps to reproduce
No response
poolifier version
0.4.14
Javascript runtime
Deno
Deno, Bun or browser version
deno 1.44.4 (release, x86_64-unknown-linux-gnu) v8 12.6.228.9 typescript 5.4.5
System
No response
Attachments
No response
The text was updated successfully, but these errors were encountered: