Skip to content
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

Impress doesn't restart worker if it crush on "JS heap out of memory" #1960

Closed
MarhiievHE opened this issue Feb 8, 2024 · 0 comments · Fixed by #1961
Closed

Impress doesn't restart worker if it crush on "JS heap out of memory" #1960

MarhiievHE opened this issue Feb 8, 2024 · 0 comments · Fixed by #1961
Labels

Comments

@MarhiievHE
Copy link
Member

MarhiievHE commented Feb 8, 2024

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:

process.on('uncaughtException', logError('Uncaught exception'));
.
Since we don't catch worker errors, this "ERR_WORKER_OUT_OF_MEMORY" exit code does not go to the "exit" event listener:
worker.on('exit', (code) => {
.

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

image image image

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);
  });
image
@MarhiievHE MarhiievHE added the bug label Feb 8, 2024
tshemsedinov added a commit that referenced this issue Feb 11, 2024
tshemsedinov added a commit that referenced this issue Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant