Skip to content

[BUG] onShutdown events not working #481

@Neptnium

Description

@Neptnium

Fill out general information
OS (windows, linux, ...): debian12
BeamMP-Server Version: v3.9.2

Describe the bug
The onShutdown event is not working as intended, as the LuaEngine (TLuaEngine) is created AFTER the registration for the Handler dispatcher for the onShutdown event.
AND, that the RegisterShutdownHandler method, is doing a push_front.

To Reproduce
Steps to reproduce the behavior:

  1. Have a plugin with a onShutdown event and some code inside it
  2. Shutdown the server
    (Look below for full code example)

Expected behavior
On shutdown working, I guess ?

Logs

[04/04/26 11:28:34] [INFO] gracefully shutting down
[04/04/26 11:28:34] [INFO] please wait while all subsystems are shutting down...
[04/04/26 11:28:34] [INFO] Subsystem 1/9 shutting down
[04/04/26 11:28:34] [INFO] Subsystem 2/9 shutting down
[04/04/26 11:28:34] [INFO] Subsystem 3/9 shutting down
[04/04/26 11:28:34] [INFO] Subsystem 4/9 shutting down
[04/04/26 11:28:34] [INFO] Subsystem 5/9 shutting down
[04/04/26 11:28:34] [INFO] Subsystem 6/9 shutting down
[04/04/26 11:28:34] [INFO] Subsystem 7/9 shutting down
[04/04/26 11:28:34] [INFO] Subsystem 8/9 shutting down
[04/04/26 11:28:39] [LUA WARN] 'testShutdownHandler' in 'test' failed to execute in time and was not waited for. It may still finish executing at a later time.
[04/04/26 11:28:39] [INFO] Subsystem 9/9 shutting down
[04/04/26 11:28:39] [INFO] If this takes too long, you can press Ctrl+C repeatedly to force a shutdown.
[04/04/26 11:28:39] [INFO] Shutdown.
[04/04/26 11:28:39] [INFO] Scoped timer: "" took 15133ms

ExampleCode

function testShudownHandler()
    print("Shutdown event received, exiting...")
end

MP.RegisterEvent("onShutdown", "testShudownHandler")

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions