Open
Description
Ollama Fetch Error Improvements
Background
This is a follow-up to issue #401 where a user reported "TypeError: fetch failed" errors when using MyCoder with Ollama.
Proposed Changes
- Update the Ollama npm package to the latest version (currently using 0.5.14, latest is 0.5.15)
- Improve error handling in the OllamaProvider class to provide more informative error messages:
- Add specific error handling for network connectivity issues
- Provide clearer error messages when the Ollama server is unreachable
- Handle large model loading failures more gracefully
- Add a health check for the Ollama server before attempting to use it
- Add documentation on troubleshooting Ollama connectivity issues
Implementation Plan
- Update the Ollama dependency in packages/agent/package.json
- Enhance the OllamaProvider class with better error handling:
try { // Make the API request using the Ollama client const response: OllamaChatResponse = await this.client.chat({ ...requestOptions, stream: false, }); // Process response... } catch (error) { // Enhanced error handling if (error.message.includes('fetch failed')) { throw new Error('Failed to connect to Ollama server. Please ensure Ollama is running and accessible.'); } // Handle other specific errors... throw error; }
- Add a health check method to verify Ollama server status
- Update documentation with troubleshooting tips
Testing Plan
- Test with Ollama server running/not running
- Test with various network configurations
- Test with different model sizes
- Verify error messages are user-friendly and actionable
Related Issues
- "TypeError: fetch failed" when trying to use ollama #401 "TypeError: fetch failed" when trying to use ollama