Skip to content

Commit 283597d

Browse files
committed
fix(startup): capture exception message before deferred telemetry lambda
1 parent 33979d3 commit 283597d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

UnityMcpBridge/UnityMcpServer~/src/server.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,25 @@ def _emit_startup():
114114

115115
# Record connection failure (deferred)
116116
import threading as _t
117+
_err_msg = str(e)[:200]
117118
_t.Timer(1.0, lambda: record_telemetry(
118119
RecordType.UNITY_CONNECTION,
119120
{
120121
"status": "failed",
121-
"error": str(e)[:200],
122+
"error": _err_msg,
122123
"connection_time_ms": (time.perf_counter() - start_clk) * 1000,
123124
}
124125
)).start()
125126
except Exception as e:
126127
logger.warning("Unexpected error connecting to Unity on startup: %s", e)
127128
_unity_connection = None
128129
import threading as _t
130+
_err_msg = str(e)[:200]
129131
_t.Timer(1.0, lambda: record_telemetry(
130132
RecordType.UNITY_CONNECTION,
131133
{
132134
"status": "failed",
133-
"error": str(e)[:200],
135+
"error": _err_msg,
134136
"connection_time_ms": (time.perf_counter() - start_clk) * 1000,
135137
}
136138
)).start()

0 commit comments

Comments
 (0)