{"version":"2.1.260","anchor":"session-watchdog-max-lifetime-kill-decision-can-be-overridde","canonical_anchor":"self-hosted-runner-session-gets-lifecycle-hooks-and-current","heading":"Background session runner gains an onMaxLifetime lifecycle hook","tier":"internal","area":"Sessions","scope":null,"heads_up":null,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.260\/e\/session-watchdog-max-lifetime-kill-decision-can-be-overridde","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.260","markdown":"### Background session runner gains an onMaxLifetime lifecycle hook\n\nA hook can now override whether a background session gets killed at its max lifetime.\n\nThe child-process session manager (`mr`\/`Sr`) constructor now accepts `onMaxLifetime` and `onTerminating` callbacks, and the created instance is stored on a ref (`St.current`) so other code can reach the active runner session, e.g. to check `terminationRequested`. The background-session runner's max-lifetime timeout now calls the `onMaxLifetime` hook to decide whether to wait or kill the child process, instead of always killing unless a turn is in flight; hook errors fall back to the previous default behavior. The background-result follow-up clear callback also now reports whether termination was requested (`B?.(!1, k || St.current?.terminationRequested === !0)`).\n\n- Area: Sessions\n- Names: `onMaxLifetime`\n- Tier: Under the hood\n- Useful: 2\/5\n- Signal: 2\/5"}