From 0da6929e57eeea47ce4dfe737a65fa83bf3ee638 Mon Sep 17 00:00:00 2001 From: Rishet Mehra Date: Sat, 25 Jul 2026 02:07:43 +0530 Subject: [PATCH] fix(hooks): match the post-checkout log prefix in the timeout fallback The post-checkout body logs with [graphify] throughout, but the new non-SIGALRM fallback used [graphify hook], so the same timeout read differently depending on the platform. The post-commit body does use [graphify hook] everywhere, so only the checkout copy was wrong. Assert each body uses a single log prefix so this cannot drift again. --- graphify/hooks.py | 2 +- tests/test_hooks.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/graphify/hooks.py b/graphify/hooks.py index 455c70a4..afb45588 100644 --- a/graphify/hooks.py +++ b/graphify/hooks.py @@ -171,7 +171,7 @@ try: signal.alarm(_timeout) else: def _bail(): - print(f'[graphify hook] graphify rebuild exceeded {_timeout}s', flush=True) + print(f'[graphify] graphify rebuild exceeded {_timeout}s', flush=True) os._exit(1) _watchdog = threading.Timer(_timeout, _bail) _watchdog.daemon = True diff --git a/tests/test_hooks.py b/tests/test_hooks.py index f21b7e31..3ea7ed2b 100644 --- a/tests/test_hooks.py +++ b/tests/test_hooks.py @@ -348,6 +348,11 @@ def test_rebuild_bodies_arm_a_timeout_without_sigalrm(name, body): dumped = "".join(ast.dump(stmt) for stmt in fallbacks[0]) assert "attr='Timer'" in dumped, f"{name} fallback does not arm a threading.Timer (#2148)" assert "attr='_exit'" in dumped, f"{name} fallback does not kill the stuck rebuild (#2148)" + # The fallback logs the timeout itself, because os._exit skips the except + # handler that reports it on the SIGALRM path. Its prefix has to match the + # rest of the body, or the same event reads differently per platform. + prefixes = set(re.findall(r"print\(f'\[([a-z ]+)\]", body)) + assert len(prefixes) == 1, f"{name} mixes log prefixes {sorted(prefixes)} (#2148)" def test_detached_launch_targets_graphify_python():