Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2258,6 +2258,11 @@ class Server {
this.middleware = null;
}
}

// We add listeners to signals when creating a new Server instance
// So ensure they are removed to prevent EventEmitter memory leak warnings
process.removeAllListeners("SIGINT");
process.removeAllListeners("SIGTERM");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not remove all of them just only our, move our close function above the file and use removeListener

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

above where?

@alexander-akait alexander-akait Nov 8, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhere here https://github.com/webpack/webpack-dev-server/blob/master/lib/Server.js#L17, like

if (needForceShutdown) {
            exitProcess();
          }

          this.logger.info(
            "Gracefully shutting down. To force exit, press ^C again. Please wait..."
          );

          needForceShutdown = true;

          this.stopCallback(() => {
            if (typeof this.compiler.close === "function") {
              this.compiler.close(exitProcess);
            } else {
              exitProcess();
            }
});

from https://github.com/webpack/webpack-dev-server/blob/master/lib/Server.js#L1177

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I.e. just move it in function above the Server class and remove this listener in close

}

stopCallback(callback) {
Expand Down