@@ -361,11 +361,12 @@ impl RegistryDispatcher {
361361 let ( workflow_supported, workflow_history) =
362362 self . inspector_workflow_history_bytes ( instance) . await ?;
363363 let queue_size = self . inspector_current_queue_size ( instance) . await ?;
364+ let is_state_enabled = instance. ctx . has_state ( ) ;
364365 Ok ( InspectorServerMessage :: Init (
365366 inspector_protocol:: InitMessage {
366367 connections : inspector_wire_connections ( & instance. ctx ) ,
367- state : Some ( instance. ctx . state ( ) ) ,
368- is_state_enabled : instance . ctx . has_state ( ) ,
368+ state : inspector_state_payload ( & instance. ctx , is_state_enabled ) ,
369+ is_state_enabled,
369370 rpcs : inspector_rpcs ( instance) ,
370371 is_database_enabled : instance. ctx . sql ( ) . is_enabled ( ) ,
371372 queue_size : serde_bare:: Uint ( queue_size) ,
@@ -380,10 +381,11 @@ impl RegistryDispatcher {
380381 instance : & ActorTaskHandle ,
381382 rid : serde_bare:: Uint ,
382383 ) -> inspector_protocol:: StateResponse {
384+ let is_state_enabled = instance. ctx . has_state ( ) ;
383385 inspector_protocol:: StateResponse {
384386 rid,
385- state : Some ( instance. ctx . state ( ) ) ,
386- is_state_enabled : instance . ctx . has_state ( ) ,
387+ state : inspector_state_payload ( & instance. ctx , is_state_enabled ) ,
388+ is_state_enabled,
387389 }
388390 }
389391
@@ -468,3 +470,15 @@ impl RegistryDispatcher {
468470 }
469471 }
470472}
473+
474+ /// Returns the actor state bytes for inspector wire payloads, or `None` when
475+ /// state is disabled or has not been initialized yet. Sending `Some(empty)`
476+ /// would cause the inspector frontend to attempt a CBOR decode of zero bytes
477+ /// and fail with "Unexpected end of CBOR data".
478+ fn inspector_state_payload ( ctx : & ActorContext , is_state_enabled : bool ) -> Option < Vec < u8 > > {
479+ if !is_state_enabled {
480+ return None ;
481+ }
482+ let state = ctx. state ( ) ;
483+ if state. is_empty ( ) { None } else { Some ( state) }
484+ }
0 commit comments