LM1LC3N7 / nodebb-plugin-private-forum

A NodeBB plugin to lockdown the forum to non-registered users.
MIT License
3 stars 1 forks source link

Crashes on register with nodebb v1.19.1 #3

Closed ghost closed 2 years ago

ghost commented 2 years ago

With v1.19.1 and this plugin version 1.2.0, there is a crash trying to register a new user.

I confirmed the plugin as the cause by disabling, rebuild/restart and it works fine. However with the plugin enabled again, rebuild/restart, the error reproduces every time.

I also have registrations by invite only if that matters, likely not though? I am running node v16.13.2.

Happy to get more information or help test things if you need it.

Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  | 2022-01-27T21:37:52.676Z [4567/481] - error: uncaughtException: Cannot set headers after they are sent to the client
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  | Error: Cannot set headers after they are sent to the client
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  |     at new NodeError (node:internal/errors:371:5)
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  |     at ServerResponse.setHeader (node:_http_outgoing:576:11)
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  |     at ServerResponse.header (/usr/src/app/node_modules/express/lib/response.js:776:10)
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  |     at ServerResponse.contentType (/usr/src/app/node_modules/express/lib/response.js:604:15)
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  |     at ServerResponse.sendStatus (/usr/src/app/node_modules/express/lib/response.js:362:8)
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  |     at helpers.formatApiResponse (/usr/src/app/src/controllers/helpers.js:419:14)
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  |     at Object.wrapperCallback [as formatApiResponse] (/usr/src/app/src/promisify.js:46:11)
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  |     at Users.redirectBySlug (/usr/src/app/src/controllers/write/users.js:33:11)
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  |     at processTicksAndRejections (node:internal/process/task_queues:96:5) {"date":"Thu Jan 27 2022 21:37:52 GMT+0000 (Coordinated Universal Time)","error":{"code":"ERR_HTTP_HEADERS_SENT"},"exception":true,"os":{"loadavg":[1.6,1.05,0.67],"uptime":1015962.47},"process":{"argv":["/usr/local/bin/node","/usr/src/app/app.js"],"cwd":"/usr/src/app","execPath":"/usr/local/bin/node","gid":0,"memoryUsage":{"arrayBuffers":28557000,"external":35098422,"heapTotal":179478528,"heapUsed":173575224,"rss":273960960},"pid":481,"uid":0,"version":"v16.13.2"},"stack":"Error: Cannot set headers after they are sent to the client\n    at new NodeError (node:internal/errors:371:5)\n    at ServerResponse.setHeader (node:_http_outgoing:576:11)\n    at ServerResponse.header (/usr/src/app/node_modules/express/lib/response.js:776:10)\n    at ServerResponse.contentType (/usr/src/app/node_modules/express/lib/response.js:604:15)\n    at ServerResponse.sendStatus (/usr/src/app/node_modules/express/lib/response.js:362:8)\n    at helpers.formatApiResponse (/usr/src/app/src/controllers/helpers.js:419:14)\n    at Object.wrapperCallback [as formatApiResponse] (/usr/src/app/src/promisify.js:46:11)\n    at Users.redirectBySlug (/usr/src/app/src/controllers/write/users.js:33:11)\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)","trace":[{"column":5,"file":"node:internal/errors","function":"new NodeError","line":371,"method":null,"native":false},{"column":11,"file":"node:_http_outgoing","function":"ServerResponse.setHeader","line":576,"method":"setHeader","native":false},{"column":10,"file":"/usr/src/app/node_modules/express/lib/response.js","function":"ServerResponse.header","line":776,"method":"header","native":false},{"column":15,"file":"/usr/src/app/node_modules/express/lib/response.js","function":"ServerResponse.contentType","line":604,"method":"contentType","native":false},{"column":8,"file":"/usr/src/app/node_modules/express/lib/response.js","function":"ServerResponse.sendStatus","line":362,"method":"sendStatus","native":false},{"column":14,"file":"/usr/src/app/src/controllers/helpers.js","function":"helpers.formatApiResponse","line":419,"method":"formatApiResponse","native":false},{"column":11,"file":"/usr/src/app/src/promisify.js","function":"Object.wrapperCallback [as formatApiResponse]","line":46,"method":"wrapperCallback [as formatApiResponse]","native":false},{"column":11,"file":"/usr/src/app/src/controllers/write/users.js","function":"Users.redirectBySlug","line":33,"method":"redirectBySlug","native":false},{"column":5,"file":"node:internal/process/task_queues","function":"processTicksAndRejections","line":96,"method":null,"native":false}]}
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  | 2022-01-27T21:37:52.677Z [4567/481] - error: Error: Cannot set headers after they are sent to the client
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  |     at new NodeError (node:internal/errors:371:5)
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  |     at ServerResponse.setHeader (node:_http_outgoing:576:11)
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  |     at ServerResponse.header (/usr/src/app/node_modules/express/lib/response.js:776:10)
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  |     at ServerResponse.contentType (/usr/src/app/node_modules/express/lib/response.js:604:15)
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  |     at ServerResponse.sendStatus (/usr/src/app/node_modules/express/lib/response.js:362:8)
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  |     at helpers.formatApiResponse (/usr/src/app/src/controllers/helpers.js:419:14)
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  |     at Object.wrapperCallback [as formatApiResponse] (/usr/src/app/src/promisify.js:46:11)
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  |     at Users.redirectBySlug (/usr/src/app/src/controllers/write/users.js:33:11)
Jan 27 13:37:52 earthship docker-compose[1038388]: lavender_1  |     at processTicksAndRejections (node:internal/process/task_queues:96:5)
LM1LC3N7 commented 2 years ago

As I no longer have a nodebb forum to try it, I made a blind modification and released an 1.2.1 version. But I am really unsure this could solve the error.

The error is saying a request was sent by the server after another response was made. As you can only answer once per client request, this is generating an error.

ghost commented 2 years ago

I will test and let you know, thank you 🤓

ghost commented 2 years ago

no luck with this fix. I will see if I can debug and figure out a solution.

LM1LC3N7 commented 2 years ago

Can you also start the forum in dev mode, and regenerate the error again? Logs will be usefull to understand.

LM1LC3N7 commented 2 years ago

Hello, can you try again with the latest version 1.3.0?

LM1LC3N7 commented 2 years ago

Based on the other issue, this one is likely to be solved also. I am waiting for your confirmation before closing it.

ghost commented 2 years ago

This issue is fixed with the latest version.

Thank you for your help and time.