Today I’m getting this error randomly, trying now several hours to find the problem but it keeps happening sometimes. It crashes my app so it’s critical. Can anyone help?
It often happens when using something with socket.
TypeError: this.res.cookie is not a function
at App.setCookie (/opt/node_app/lib/core/app.js:105:22)
at DatabaseProvider.login (/opt/node_app/lib/auth/provider.js:60:26)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async DatabaseProvider.autoLogin (/opt/node_app/lib/auth/provider.js:38:23)
at async App.setAuthProvider (/opt/node_app/lib/core/app.js:181:33)
at async App.getAuthProvider (/opt/node_app/lib/core/app.js:197:20)
at async App.restrict (/opt/node_app/lib/modules/auth.js:48:26)
at async App._exec (/opt/node_app/lib/core/app.js:481:30)
at async App._exec (/opt/node_app/lib/core/app.js:452:17)
at async App.exec (/opt/node_app/lib/core/app.js:421:9)
/opt/node_app/lib/core/app.js:116
this.res.clearCookie(name, {
^
TypeError: this.res.clearCookie is not a function
at App.removeCookie (/opt/node_app/lib/core/app.js:116:18)
at DatabaseProvider.logout (/opt/node_app/lib/auth/provider.js:68:18)
at DatabaseProvider.login (/opt/node_app/lib/auth/provider.js:45:24)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
I don’t understand why suddenly there is a problem related with setting and clearing cookies, and why it happens after using the same functionalities in the app for a couple times…
The problem happens only on the digitalocean server, on local there is no problem…
Still having issues with this… Can you please help, it keeps crashing the app, can’t continue to develop until this is solved…
Just now it happened again, got this from the webserver-log, so this is what happens step by step:
server-connect:app Executing action step restrict +10ms
server-connect:app options: { provider: 'securityprov', permissions: [] } +0ms
server-connect:auth Login with cookie: { username: 'wick', password: '123' } +28s
server-connect:auth setCookie 1 wick 123 +3ms
/opt/node_app/lib/core/app.js:105
this.res.cookie(name, value, opts);
^
TypeError: this.res.cookie is not a function
at App.setCookie (/opt/node_app/lib/core/app.js:105:22)
at DatabaseProvider.login (/opt/node_app/lib/auth/provider.js:60:26)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async DatabaseProvider.autoLogin (/opt/node_app/lib/auth/provider.js:38:23)
at async App.setAuthProvider (/opt/node_app/lib/core/app.js:181:33)
at async App.getAuthProvider (/opt/node_app/lib/core/app.js:197:20)
at async App.restrict (/opt/node_app/lib/modules/auth.js:48:26)
at async App._exec (/opt/node_app/lib/core/app.js:481:30)
at async App._exec (/opt/node_app/lib/core/app.js:452:17)
at async App.exec (/opt/node_app/lib/core/app.js:421:9)
It seems a problem with the security provider / cookies stuff. I built the security provider with all the documentation and it didn’t give such problems until recently.
I checked all changed files in the git manager that are related to the security provider but couldn’t find anything that’s changed that might caused this issue.
I also tried to completely redo the security provider and changed all server actions using the security provider to the new one but it didn’t help too.
I’m not sure why it would give any error. The only reason I know when this happens is when a server action is being called from somewhere else then using the browser, for example using the scheduler. Then there is no response object and you would get this error.
Is it easy to reproduce the error, does it happen each time or is it happening random?
Hi Patrick, unfortunately it’s happening randomly. Every time when using a different server action, sometimes every couple min, sometimes it’s fine for hours. It’s a big problem because it’s crashes the digitalocean server and the production app goes down