Skip to content

Restarting current resource within itself results in server crash #1421

Open

Description

@mythicalbro
const currentResourceName = GetCurrentResourceName();

RegisterCommand(`restart:${currentResourceName}`, () => {
  // Works
  //   ExecuteCommand(`restart ${currentResourceName}`);

  // Crashes
  setImmediate(() => ExecuteCommand(`restart ${currentResourceName}`));
});

// Crashes
// setTimeout(() => ExecuteCommand(`restart ${currentResourceName}`), 1e3);

Activity

  1. blattersturm commented on Apr 24, 2022

    @blattersturm
    Contributor

    This isn't fixable for obvious reasons and there's already logic preventing this for the intended natives such as STOP_RESOURCE.

    The best we can do is just prevent a stop/start of a currently-executing resource, but you haven't provided much.. details.

  2. mythicalbro commented on Apr 24, 2022

    @mythicalbro
    Author

    Alright, so I have to add the command to separate resource to fix that.
    The reason why I need separate command for restarting specific resource is because only players with specific ace permission should be able to restart this specific resource. I don't want to give players permission for restart command as they could restart any resource which should not be restarted.

  3. OneEarJoe5 commented on Nov 14, 2026

    @OneEarJoe5

    Still happens on current master, and not only for JS: Lua crashes the same way, and so does A calling an export of B that restarts A. Opened a PR that runs stop / restart / ensure for a resource that's still on the stack on the next tick instead, so a self restart just works now: #4403

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions