@@ -157,30 +157,17 @@ impl Api {
157157 None
158158 } ;
159159
160- let snapshot = if let Some ( params) = & request. params {
161- params
162- . get ( "snapshot" )
163- . and_then ( |v| v. as_bool ( ) )
164- . unwrap_or ( false )
165- } else {
166- false
167- } ;
168-
169- let mut logs = zinit. logs ( !snapshot) . await ;
160+ // Always fetch a snapshot, ignore client's 'snapshot' parameter
161+ let mut logs = zinit. logs ( false ) . await ; // Request snapshot
170162 let mut log_data = Vec :: new ( ) ;
171163
172- // A simplified implementation that collects logs with tokio::time::timeout
164+ // Use a short timeout to collect available logs from the snapshot receiver
173165 use tokio:: time:: { timeout, Duration } ;
174-
175- // For snapshot, wait only a short time; for continuous logs, wait longer
176- let wait_duration = if snapshot {
177- Duration :: from_millis ( 500 )
178- } else {
179- Duration :: from_secs ( 5 )
180- } ;
166+ const SNAPSHOT_TIMEOUT : Duration = Duration :: from_millis ( 500 ) ; // Short timeout for snapshot
181167
182168 loop {
183- match timeout ( wait_duration, logs. recv ( ) ) . await {
169+ // Use the fixed short timeout
170+ match timeout ( SNAPSHOT_TIMEOUT , logs. recv ( ) ) . await {
184171 Ok ( Some ( line) ) => {
185172 // Got a log line
186173 if let Some ( filter_text) = filter {
@@ -191,9 +178,7 @@ impl Api {
191178 log_data. push ( line. to_string ( ) ) ;
192179 }
193180
194- if snapshot && !log_data. is_empty ( ) {
195- break ; // For snapshot mode, get only the first logs
196- }
181+ // No need for the specific snapshot break condition anymore
197182 }
198183 Ok ( None ) => break , // Stream ended
199184 Err ( _) => break , // Timeout
0 commit comments