@@ -147,12 +147,12 @@ function extractTitle(filename: string): string {
147147 // Example: "workers/configuration/index.md" -> "Configuration"
148148 const parts = filename . replace ( / \. m d x ? $ / , '' ) . split ( '/' )
149149 const lastPart = parts [ parts . length - 1 ]
150-
150+
151151 if ( lastPart === 'index' ) {
152152 // Use the parent directory name if filename is index
153153 return parts [ parts . length - 2 ] || 'Documentation'
154154 }
155-
155+
156156 // Convert kebab-case or snake_case to title case
157157 return lastPart
158158 . replace ( / [ - _ ] / g, ' ' )
@@ -167,20 +167,20 @@ function extractTitle(filename: string): string {
167167async function doWithRetries < T > ( action : ( ) => Promise < T > ) {
168168 const NUM_RETRIES = 5
169169 const INIT_RETRY_MS = 100
170-
170+
171171 for ( let i = 0 ; i <= NUM_RETRIES ; i ++ ) {
172172 try {
173173 return await action ( )
174174 } catch ( e ) {
175175 // Check if error is retryable (system errors, not user errors)
176176 const isRetryable = isRetryableError ( e )
177-
177+
178178 console . error ( `AI Search attempt ${ i + 1 } failed:` , e )
179-
179+
180180 if ( ! isRetryable || i === NUM_RETRIES ) {
181181 throw e
182182 }
183-
183+
184184 // Exponential backoff with jitter
185185 const delay = Math . random ( ) * INIT_RETRY_MS * Math . pow ( 2 , i )
186186 await scheduler . wait ( delay )
@@ -200,7 +200,7 @@ function isRetryableError(error: unknown): boolean {
200200 // Retry server errors (5xx) and rate limits (429), not client errors (4xx)
201201 return status >= 500 || status === 429
202202 }
203-
203+
204204 // Handle network errors, timeouts, etc.
205205 if ( error instanceof Error ) {
206206 const errorMessage = error . message . toLowerCase ( )
@@ -211,7 +211,7 @@ function isRetryableError(error: unknown): boolean {
211211 errorMessage . includes ( 'fetch' )
212212 )
213213 }
214-
214+
215215 // Default to retryable for unknown errors (conservative approach)
216216 return true
217217}
0 commit comments