@@ -102,6 +102,18 @@ async function findMarkerRequestEntry(s3, bucket, beforeSet, marker) {
102102 return null ;
103103}
104104
105+ async function findAnyNewRequestEntry ( s3 , bucket , beforeSet , chatId ) {
106+ const keys = await listKeys ( s3 , bucket , 'logs/requests/' ) ;
107+ const candidates = keys . filter ( ( k ) => ! beforeSet . has ( k ) ) . slice ( - 120 ) ;
108+ for ( let i = candidates . length - 1 ; i >= 0 ; i -= 1 ) {
109+ const key = candidates [ i ] ;
110+ const obj = await readJson ( s3 , bucket , key ) ;
111+ if ( chatId && Number ( obj ?. chatId || 0 ) !== Number ( chatId ) ) continue ;
112+ return { key, obj } ;
113+ }
114+ return null ;
115+ }
116+
105117async function loadR2Diagnostics ( s3 , bucket ) {
106118 const out = { latestCrash : null , latestRequests : [ ] } ;
107119 try {
@@ -274,7 +286,7 @@ async function main() {
274286 console . log ( '[sanity] wait for request log marker' ) ;
275287 const requestEntry = await waitFor ( async ( ) => {
276288 await assertHealth ( baseUrl , 'request-log-wait' ) ;
277- const found = await findMarkerRequestEntry ( s3 , bucket , beforeReq , marker ) ;
289+ const found = await findAnyNewRequestEntry ( s3 , bucket , beforeReq , chatId ) ;
278290 if ( ! found ) return false ;
279291 if ( found . obj && found . obj . result && found . obj . result . ok === false ) {
280292 throw new Error ( `Remote generation failed early: ${ String ( found . obj . result . error || 'unknown error' ) } ` ) ;
0 commit comments