ForestAdmin / forest-express

🧱 Dependency of Express Lianas for Forest Admin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Server events subscription inhibits graceful shutdown

ChrisLahaye opened this issue · comments

Hello,

Applications with recent versions of forest-express, those that include the server events subscription, do not gracefully shut down.

This is caused by the commit b5db483#diff-bfe9874d239014961b1ae4e89875a6155667db834a410aaaa2ebe3cf89820556R379.

This commit introduces an EventSource subscription which is never properly closed. Since this subscription opens resources that cannot accessed or closed upon shutdown, the process cannot gracefully exit.

How can we close this subscription?

Hello @ChrisLahaye,

Thanks for reporting the issue. We'll take a look and keep you posted when it'll be fixed.

Hello @ChrisLahaye,

Thanks for the report. 🙏

  • Do you have any logs to share?
  • Does the SSE properly connect first?

Thanks for your answers.
Morgan

Hi @Thenkei!

Unfortunately I don't have logs to share because those were not emitted. About whether the SSE properly connects, I wouldn't know, I don't have any experience with EventSource. I do know that my process only terminates gracefully when commenting out the line await inject().forestAdminClient.subscribeToServerEvents(), that the EventSource has a close function which isn't called or exposed, and that EventSource probably creates handles, similarly as websockets, timers, and timeouts, that need to be properly closed for the process to gracefully exit.

We deactivated the EventSource for now. It didn't provide any significantly different experience on the agent forest-express-sequelize and forest-express-mongoose.

We just released some new versions of our agents.

  • forest-express-sequelize v9.3.3
  • forest-express-mongoose v9.3.2

Let me know if it's ok on your side.
Again, thanks for the report 🙏

We pumped to forest-express-mongoose v9.3.2 and the issue is fixed. Thank you 😇