node-red-dashboard icon indicating copy to clipboard operation
node-red-dashboard copied to clipboard

Nodered crash when loading dist/js file

Open pheex opened this issue 1 year ago • 0 comments

What are the steps to reproduce?

not able to reproduce it, so maybe link to network race condition

What happens?

Nodered process crash when serving js file on dashboard loading

8 Jan 15:02:51 - [red] Uncaught Exception: - - 8 Jan 15:02:51 - Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client - - at ServerResponse.setHeader (_http_outgoing.js:470:11) - - at ServerResponse.header (/usr/src/node-red/node_modules/express/lib/response.js:771:10) - - at ServerResponse.contentType (/usr/src/node-red/node_modules/express/lib/response.js:599:15) - - at ServerResponse.sendStatus (/usr/src/node-red/node_modules/express/lib/response.js:357:8) - - at /usr/src/node-red/node_modules/node-red-dashboard/nodes/ui_base.js:99:21 - - at /usr/src/node-red/node_modules/express/lib/response.js:434:22 - - at onerror (/usr/src/node-red/node_modules/express/lib/response.js:1044:5) - - at Array.onfinish (/usr/src/node-red/node_modules/express/lib/response.js:1062:21) - - at listener (/usr/src/node-red/node_modules/on-finished/index.js:169:15) - - at onFinish (/usr/src/node-red/node_modules/on-finished/index.js:100:5) - - at callback (/usr/src/node-red/node_modules/ee-first/index.js:55:10) - - at Socket.onevent (/usr/src/node-red/node_modules/ee-first/index.js:93:5) - - at Socket.emit (events.js:203:15) - - at errorOrDestroy (internal/streams/destroy.js:107:12) - - at onwriteError (_stream_writable.js:430:5) - - at onwrite (_stream_writable.js:461:5)

What do you expect to happen?

no header sent twice and not nodered crash

Maybe on this block code, the sendStatus is sending again the header, and if previous sendfile has already send the header and got a connection close error, the ERR_HTTP_HEADERS_SENT is triggered The sendfile can return network error, not only not found file error

RED.httpAdmin.get('/ui_base/js/*', function(req, res) { res.sendFile(req.params[0], optsjs, function (err) { if (err) { res.sendStatus(404);

pheex avatar Jan 10 '25 10:01 pheex