Impress doesn't restart worker if it crush on "JS heap out of memory"
MarhiievHE opened this issue · 0 comments
MarhiievHE commented
Impress and Node.js versions
impress: 3.0.13, node: 18 & 20
Platform
No response
Describe the bug
Impress will not restart the worker if it crashes with error code ERR_WORKER_OUT_OF_MEMORY. This error is not caught by the worker and goes to the uncaught errors listener here:
Line 218 in df4c4c4
Since we don't catch worker errors, this "ERR_WORKER_OUT_OF_MEMORY" exit code does not go to the "exit" event listener:
Line 72 in df4c4c4
To Reproduce
Create endpoint that make memory leak, to example:
({
access: 'public',
method: async () => {
const array = [];
while (true) {
array.push(new Array(1000000));
}
},
});
Expected behavior
Impress should restart the fallen worker.
Screenshots
Additional context
To fix it, all you need to do is to add a listener to the error events of the worker such as this one:
worker.on('error', (error) => {
impress.console.error('Error in worker : ', error);
});