SoftwareBrothers / adminjs

AdminJS is an admin panel for apps written in node.js
https://adminjs.co
MIT License
8.19k stars 662 forks source link

AdminJs crashes after some hours of working fine #1256

Closed CodahWasTaken closed 2 years ago

CodahWasTaken commented 2 years ago

Describe the bug After some hours of having adminjs express server running in my ubuntu server it stops working with the following error:

Error: bad content-type header, unknown content-type: text/xml; charset="utf-8"
    at IncomingForm._parseContentType (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/formidable/lib/incoming_form.js:293:15)
    at IncomingForm.writeHeaders (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/formidable/lib/incoming_form.js:144:8)
    at IncomingForm.parse (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/formidable/lib/incoming_form.js:112:8)
    at /home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/express-formidable/lib/middleware.js:29:10
    at Layer.handle [as handle_request] (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/express/lib/router/index.js:328:13)
    at /home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/express/lib/router/index.js:286:9
    at Function.process_params (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/express/lib/router/index.js:346:12)
    at next (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/express/lib/router/index.js:280:10)
    at session (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/express-session/index.js:479:7)
Error: bad content-type header, unknown content-type: text/xml; charset="utf-8"
    at IncomingForm._parseContentType (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/formidable/lib/incoming_form.js:293:15)
    at IncomingForm.writeHeaders (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/formidable/lib/incoming_form.js:144:8)
    at IncomingForm.parse (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/formidable/lib/incoming_form.js:112:8)
    at /home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/express-formidable/lib/middleware.js:29:10
    at Layer.handle [as handle_request] (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/express/lib/router/index.js:328:13)
    at /home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/express/lib/router/index.js:286:9
    at Function.process_params (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/express/lib/router/index.js:346:12)
    at next (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/express/lib/router/index.js:280:10)
    at session (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/express-session/index.js:479:7)
node:_http_outgoing:654
    throw new ERR_HTTP_HEADERS_SENT('remove');
    ^

Error [ERR_HTTP_HEADERS_SENT]: Cannot remove headers after they are sent to the client
    at new NodeError (node:internal/errors:372:5)
    at ServerResponse.removeHeader (node:_http_outgoing:654:11)
    at write (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/finalhandler/index.js:282:9)
    at AsyncResource.runInAsyncScope (node:async_hooks:202:9)
    at listener (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/on-finished/index.js:170:15)
    at onFinish (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/on-finished/index.js:101:5)
    at callback (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/ee-first/index.js:55:10)
    at Socket.onevent (/home/ubuntu/Desktop/myusername/AdminDashboard/node_modules/ee-first/index.js:93:5)
    at Socket.emit (node:events:539:35)
    at emitErrorNT (node:internal/streams/destroy:157:8) {
  code: 'ERR_HTTP_HEADERS_SENT'
}
dziraf commented 2 years ago

It's difficult to guess what's the exact cause is but it looks to be coming from express-session. Have you set up a session store for your user sessions or does it keep them in server's memory?

CodahWasTaken commented 2 years ago

No, I probably haven't.

CodahWasTaken commented 2 years ago

How could I do that? I didn't read any documentation that said it required this.

dziraf commented 2 years ago

There is an example here: https://docs.adminjs.co/installation/plugins/express#authenticated

It isn't strictly required, but if your session is saved in-memory it can be lost. AFAIK when you start your server there should be a warning saying that MemoryStore isn't advised for production.

CodahWasTaken commented 2 years ago

Yes! That perfectly worked. Sorry for the delay.