Region ticker disables before plugins, disallowing plugin cleanups in the world #353

Open
opened 2025-04-23 07:17:03 +02:00 by StrangeOne101 · 12 comments
StrangeOne101 commented 2025-04-23 07:17:03 +02:00 (Migrated from github.com)

Expected behavior

N/A

Observed/Actual behavior

The region ticker disables before plugins, preventing any further ticks while shutting down.

For some plugins, who spawn entities or block modifications in the world, normally they can run cleanups in onDisable(). However, because synchronous tasks on disable cannot be done due to the lack of main thread, they have to pend this task to RegionScheduler. Which is disabled at the time onDisable() occurs.

This means some plugins cannot run their cleanup, such as removing entities, reverting block changes, etc.

Steps/models to reproduce

  1. Set a block in the world with a task
  2. Set a task to revert that block change in onDisable()
  3. Stop the server
  4. The block will not be reverted

Plugin and Datapack List

BetterScoreboard, packetevents, PlaceholderAPI, ProjectKorra, ViaBackwards, ViaVersion

Folia version

1.21.4-DEV-master@8af1aef (2025-04-11T00:37:47Z) (Implementing API version 1.21.4-R0.1-SNAPSHOT)

Other

No response

### Expected behavior N/A ### Observed/Actual behavior The region ticker disables before plugins, preventing any further ticks while shutting down. For some plugins, who spawn entities or block modifications in the world, normally they can run cleanups in `onDisable()`. However, because synchronous tasks on disable cannot be done due to the lack of main thread, they have to pend this task to RegionScheduler. Which is disabled at the time `onDisable()` occurs. This means some plugins cannot run their cleanup, such as removing entities, reverting block changes, etc. ### Steps/models to reproduce 1. Set a block in the world with a task 2. Set a task to revert that block change in `onDisable()` 3. Stop the server 4. The block will not be reverted ### Plugin and Datapack List BetterScoreboard, packetevents, PlaceholderAPI, **ProjectKorra**, ViaBackwards, ViaVersion ### Folia version 1.21.4-DEV-master@8af1aef (2025-04-11T00:37:47Z) (Implementing API version 1.21.4-R0.1-SNAPSHOT) ### Other _No response_
BopMooCow23 commented 2025-05-04 01:50:32 +02:00 (Migrated from github.com)

I also run into this issue :P

I also run into this issue :P
SpeedyGo55 commented 2025-05-04 02:36:20 +02:00 (Migrated from github.com)

I run into this issue as well

I run into this issue as well
Szyman-AirShard commented 2025-05-04 04:18:18 +02:00 (Migrated from github.com)

I also run into this issue dude.

I also run into this issue dude.
anikamunro commented 2025-05-04 06:34:00 +02:00 (Migrated from github.com)

I also run into the same issue

I also run into the same issue
Sebi4623 commented 2025-05-04 08:37:20 +02:00 (Migrated from github.com)

I also run this issue.

I also run this issue.
lancerarchive commented 2025-05-04 13:23:42 +02:00 (Migrated from github.com)

Same issue here

Same issue here
ghost commented 2025-05-04 16:10:24 +02:00 (Migrated from github.com)

This is also something I struggle with. It would be great if it can be fixed as soon as possible!

This is also something I struggle with. It would be great if it can be fixed as soon as possible!
Spottedleaf commented 2025-05-27 13:30:20 +02:00 (Migrated from github.com)

I probably need to make more uses of the regionized world data tolerant to shutdown. There are still some things that you really can't do though, like load chunks.

I probably need to make more uses of the regionized world data tolerant to shutdown. There are still some things that you really can't do though, like load chunks.
Euphillya commented 2025-06-14 20:07:03 +02:00 (Migrated from github.com)

I don't know if it would be viable, but before the server shutdown call, create some kind of event like ServerWillShutdownEvent?
But if so, it would be more on the Paper side that would need to be added.

I don't know if it would be viable, but before the server shutdown call, create some kind of event like ServerWillShutdownEvent? But if so, it would be more on the Paper side that would need to be added.
codeHusky commented 2025-07-03 19:46:05 +02:00 (Migrated from github.com)

ServerPreShutdownEvent would be good for cleanup for sure, though yes, it should exist in both Paper and Folia if added. Probably fired after Players are effectively "disconnected" (on folia, still in world, but on Paper iirc they'd be disconnected already?), though the specifics of that could be pretty easily documented and handled per platform by devs. Would, in general, be helpful since just handling onDisable is too late for many Folia API calls, plus if the server region crashes or something it could allow better, safe Plugin cleanup

ServerPreShutdownEvent would be good for cleanup for sure, though yes, it should exist in both Paper and Folia if added. Probably fired after Players are effectively "disconnected" (on folia, still in world, but on Paper iirc they'd be disconnected already?), though the specifics of that could be pretty easily documented and handled per platform by devs. Would, in general, be helpful since just handling `onDisable` is too late for many Folia API calls, plus if the server region crashes or something it could allow better, safe Plugin cleanup
electronicboy commented 2025-07-03 20:03:52 +02:00 (Migrated from github.com)

players are booted from the server long after plugins disable on paper, and changing that behavior requires a whole lot of testing as it's fairly easy for stuff to get lost if you start changing the semantics of shutting down which brings in a lot of edge case issues

players are booted from the server long after plugins disable on paper, and changing that behavior requires a whole lot of testing as it's fairly easy for stuff to get lost if you start changing the semantics of shutting down which brings in a lot of edge case issues
codeHusky commented 2025-07-03 20:05:51 +02:00 (Migrated from github.com)

@electronicboy I'm not suggesting making a change to shutdown behavior, I was just making an assertion that's probably wrong. AFAIK on Folia players are only removed from the world late into shutdown, idk what it is on Paper.

@electronicboy I'm not suggesting making a change to shutdown behavior, I was just making an assertion that's probably wrong. AFAIK on Folia players are only removed from the world late into shutdown, idk what it is on Paper.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Minecraft/Folia#353
No description provided.