File tree Expand file tree Collapse file tree 1 file changed +21
-5
lines changed
apps/hash-ai-worker-ts/src/activities/flow-activities Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ import type { GetWebSearchResults200ResponseWebSearchResultsInner } from "@local
66import { StatusCode } from "@local/status" ;
77import { backOff } from "exponential-backoff" ;
88
9+ import { logger } from "../shared/activity-logger.js" ;
10+
911export type GetWebSearchResultsResponse = Omit <
1012 GetWebSearchResults200ResponseWebSearchResultsInner ,
1113 "url"
@@ -30,11 +32,25 @@ export const webSearchAction: AiFlowActionActivity<"webSearch"> = async ({
3032
3133 const {
3234 data : { webSearchResults } ,
33- } = await backOff ( ( ) => internalApiClient . getWebSearchResults ( query ) , {
34- jitter : "full" ,
35- numOfAttempts : 3 ,
36- startingDelay : 1_000 ,
37- } ) ;
35+ } = await backOff (
36+ async ( ) => {
37+ try {
38+ return await internalApiClient . getWebSearchResults ( query ) ;
39+ } catch ( error ) {
40+ logger . error (
41+ `Error fetching web search results for query "${ query } ": ${
42+ error instanceof Error ? error . message : JSON . stringify ( error )
43+ } `,
44+ ) ;
45+ throw error ;
46+ }
47+ } ,
48+ {
49+ jitter : "full" ,
50+ numOfAttempts : 3 ,
51+ startingDelay : 1_000 ,
52+ } ,
53+ ) ;
3854
3955 const webPages = webSearchResults . slice ( 0 , numberOfSearchResults ) ;
4056
You can’t perform that action at this time.
0 commit comments