Problem
_flush_events in event_queue_manager.py has a latent UnboundLocalError that masks underlying WASM errors.
# event_queue_manager.py:86
def _flush_events(self) -> int:
if self._flush_lock.locked():
return 0
with self._flush_lock:
try:
payloads = self._local_bucketing.flush_event_queue()
except Exception as e:
logger.error(f"DevCycle: Error flushing event payloads: {str(e)}")
event_count = 0
if payloads: # <-- UnboundLocalError if exception fired above
...
return event_count
If flush_event_queue() raises (e.g. a WASMAbortError from the AssemblyScript bucketing engine trapping during flush), payloads is never assigned. The if payloads: check on line 97 then raises UnboundLocalError: local variable 'payloads' referenced before assignment.
The _flush_lock releases correctly (the with block handles that), but the UnboundLocalError propagates into run()'s generic except, which logs a vague warning. The original WASM error is effectively masked.
Context
Found during a cross-SDK audit related to dotnet-server-sdk #204, where the WASM bucketing engine traps during flush due to AssemblyScript throw new Error(...) (e.g. "Request Payload has not finished sending" in requestPayloadManager.ts:281).
The Python SDK does not have the same flush-mutex-leak as .NET (with self._flush_lock always releases), but it does have this related masking issue.
Suggested Fix
Initialize payloads before the try block:
payloads = []
try:
payloads = self._local_bucketing.flush_event_queue()
except Exception as e:
logger.error(f"DevCycle: Error flushing event payloads: {str(e)}")
Problem
_flush_eventsinevent_queue_manager.pyhas a latentUnboundLocalErrorthat masks underlying WASM errors.If
flush_event_queue()raises (e.g. aWASMAbortErrorfrom the AssemblyScript bucketing engine trapping during flush),payloadsis never assigned. Theif payloads:check on line 97 then raisesUnboundLocalError: local variable 'payloads' referenced before assignment.The
_flush_lockreleases correctly (thewithblock handles that), but theUnboundLocalErrorpropagates intorun()'s genericexcept, which logs a vague warning. The original WASM error is effectively masked.Context
Found during a cross-SDK audit related to dotnet-server-sdk #204, where the WASM bucketing engine traps during flush due to AssemblyScript
throw new Error(...)(e.g. "Request Payload has not finished sending" inrequestPayloadManager.ts:281).The Python SDK does not have the same flush-mutex-leak as .NET (
with self._flush_lockalways releases), but it does have this related masking issue.Suggested Fix
Initialize
payloadsbefore thetryblock: