-
-
Notifications
You must be signed in to change notification settings - Fork 151
process is still alive when finishing the automation #173
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
Comments
Hi 👋 Thanks for reaching out. Would it be possible to provide some code of your automation on where the error occurs? Strange behavior most likely appears due to missing |
I'm using version
unfortunately, there is a lot of abstraction in the codebase of my app, it will be hard just to provide single nut.js api calls that reproduce this. but basically, I'm just searching images a lot with waitFor, sometimes also doing parallel searches and waiting with Promise.all() for all of them to finish, not sure if that kind of usage can generate some leaked resource/handle. anyway according to the message reported by I was trying to debug this case to find the cause, I did not find it but found another related bug with this is the flow:
here is basically the code needed to fix this case in export function timeout<R>(updateIntervalMs: number, maxDurationMs: number, action: (...params: any) => Promise<R>): Promise<R> {
return new Promise<R>((resolve, reject) => {
let interval: NodeJS.Timeout;
let isDone = false;
const maxTimeout = setTimeout(
() => {
isDone = true;
clearTimeout(maxTimeout);
if (interval) {
clearTimeout(interval);
}
reject(`Action timed out after ${maxDurationMs} ms`);
},
maxDurationMs
);
const startInterval = () => {
interval = setTimeout(function intervalFunc() {
action().then((result) => {
if (isDone) {
return;
}
if (!result) {
interval = setTimeout(intervalFunc, updateIntervalMs);
} else {
isDone = true;
clearTimeout(maxTimeout);
clearTimeout(interval);
resolve(result);
}
}).catch(() => {
if (isDone) {
return;
}
interval = setTimeout(intervalFunc, updateIntervalMs);
});
}, updateIntervalMs);
};
action().then((result) => {
if (isDone) {
return;
}
if (!result) {
startInterval();
} else {
isDone = true;
clearTimeout(maxTimeout);
resolve(result);
}
}).catch(() => {
if (isDone) {
return;
}
startInterval();
});
});
} maybe something similar is happening in the files related to the OpenCV |
Hi @bjrmatos 👋 Contributions are always welcome. Would be best to extract your Thanks for reaching out! |
will do! i will test this during the next days, will be back here with information if this happens again. sorry i was not able to submit a PR but i got burnout with some extra work :) |
just to follow up on this, we did not see any other issue through all this time, so the fix was ok 👍 |
Short summary
Seems like there is some active handle that prevents the node.js process to exit, probably related when execution the logic when trying to find a match for an image
Desired execution environment / tested on
Detailed question
I was working on my app and doing a lot of debugging and noticed that the process was not ended even when reaching the end of the execution, so i've used the why-is-node-running module to check what active resources/handles that prevent the process to exit.
here is the output of why-is-node-running:
any clue how to prevent this? maybe there is some method that am i missing to call that closes something related to the opencv?
thanks.
The text was updated successfully, but these errors were encountered: