shellscape/webpack-plugin-serve

Memmory Leak warning.

Closed this issue · 1 comments

  • Webpack Version: 5.21.2
  • Operating System (or Browser): Chrome 90 on macOS Catalina
  • Node Version: 14.15.1
  • webpack-plugin-serve Version: 1.4.1

How Do We Reproduce?

  • build the app, with liveReload or HMR,
  • reload the page, multiple times, in my case 11 times.
  • check the terminal to see the error.

--
if it helps here is the config I use

new Serve({
  host,
  port,
  static,
  status: true,
  log: { level: 'warn' },
  progress: 'minimal',
  liveReload: true,
  client: {
    address: `${hostname}:${port}`,
    retry: true,
  },
  middleware: middleware(argv),
  https: {
    key,
    cert,
    secureProtocol: 'TLSv1_2_method',
  },
})

Expected Behavior

  • no error

Actual Behavior

Terminal logs

(node:28533) MaxListenersExceededWarning: Possible EventEmitter memory leak detected.
 11 unhandled listeners added to [WebpackPluginServe]. 
 Use emitter.setMaxListeners() to increase limit
    at _addListener (events.js:390:17)
    at WebpackPluginServe.addListener (events.js:406:10)
    at Object.connect (node_modules/webpack-plugin-serve/lib/routes.js:103:12)
    at node_modules/webpack-plugin-serve/lib/middleware.js:93:7
    at middleware (node_modules/webpack-plugin-serve/lib/ws.js:34:3)
    at serve (node_modules/koa-static/index.js:53:9)
    at node_modules/webpack-plugin-serve/lib/middleware.js:104:7
    at node_modules/koa-mount/index.js:52:26
    at node_modules/koa-mount/index.js:52:26

My assumption is that in this line https://github.com/shellscape/webpack-plugin-serve/blob/master/lib/routes.js#L103 every connection registers an unhandled event, but they are never unregistered so every-time you reload, you create a new connection and a new subscription to this event. they just keep piling up.

Closed by #224