File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ export function useTask(taskId: string) {
1111 const hasFoundTaskRef = useRef ( false )
1212
1313 const fetchTask = useCallback ( async ( ) => {
14+ let errorOccurred = false
1415 try {
1516 const response = await fetch ( `/api/tasks/${ taskId } ` )
1617 if ( response . ok ) {
@@ -25,17 +26,20 @@ export function useTask(taskId: string) {
2526 if ( attemptCountRef . current >= 3 || hasFoundTaskRef . current ) {
2627 setError ( 'Task not found' )
2728 setTask ( null )
29+ errorOccurred = true
2830 }
2931 // If we haven't hit the attempt threshold yet, keep loading state
3032 } else {
3133 setError ( 'Failed to fetch task' )
34+ errorOccurred = true
3235 }
3336 } catch ( err ) {
3437 console . error ( 'Error fetching task:' , err )
3538 setError ( 'Failed to fetch task' )
39+ errorOccurred = true
3640 } finally {
3741 // Only stop loading after we've either found the task or exceeded attempt threshold
38- if ( hasFoundTaskRef . current || attemptCountRef . current >= 3 ) {
42+ if ( hasFoundTaskRef . current || attemptCountRef . current >= 3 || errorOccurred ) {
3943 setIsLoading ( false )
4044 }
4145 }
You can’t perform that action at this time.
0 commit comments