Skip to content

feat(script): fire watchdogTerminate in the pack whose script hung - #384

Merged
NaySurGithub merged 1 commit into
devfrom
feat/script-watchdog-terminate
Nov 13, 2026
Merged

NaySurGithub merged 1 commit into
devfrom
feat/script-watchdog-terminate

Conversation

@NaySurGithub

Copy link
Copy Markdown
Contributor

What

system.beforeEvents.watchdogTerminate was bound but never fired. It now fires when a pack's script runs past the script watchdog deadline:

  • the interrupt handler finds the hung pack from the running frames (the innermost frame whose file sits under a pack root)
  • once the hung code has unwound, that pack alone gets a WatchdogTerminateBeforeEvent with terminateReason: "Hang" and cancel: false, run in restricted execution like every before event
  • one event per arming: the code that trips right after an expired deadline is not a new hang

How it was checked

Client 26.60 in IDA, the scripting watchdog's handler:

  • a hang report fires the event with reason index 0 (Hang), a stack overflow report with index 1 (StackOverflow); the event carries the plugin it is about
  • after the event, when cancelling is allowed and the event was cancelled, nothing else happens; otherwise it logs an unhandled critical exception and, when shutdown is enabled, shuts the server down
  • both switches come from the world's script settings. Their values on a dedicated server are not in the client binary, so this PR does not shut anything down and cancel has nothing to stop; the interrupted call is aborted exactly as before

Not covered: StackOverflow. This server's engine reports a stack overflow as an ordinary catchable RangeError with no hook to tell it from a script's own, so there is nothing reliable to fire on.

Test: script-api-watchdog: a pack hangs in a timeout; it receives exactly one Hang event, keeps running afterwards, and a second pack subscribed to the same signal receives nothing.

Not built locally (syntax-checked with clang++ -fsyntax-only); CI runs on the branch.

AI disclosure

Code, research in the game binary and this description: Claude Opus 5.5 (claude-opus-5-5).

@NaySurGithub
NaySurGithub merged commit 5b12ac6 into dev Nov 13, 2026
13 of 15 checks passed
@NaySurGithub
NaySurGithub deleted the feat/script-watchdog-terminate branch November 13, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant