Installation Issues
Error: Cannot find module ‘context-window’
Cause: Package not installed or not found in node_modules Solution:TypeScript errors after installation
Cause: Missing type definitions or outdated TypeScript version Solution:API Key Issues
Error: “Invalid API key” (OpenAI)
Symptoms:- Error message contains “Invalid API key”
- 401 Unauthorized responses
Test API key
Error: “Invalid API key” (Pinecone)
Solutions:-
Verify key in Pinecone Console:
- Go to app.pinecone.io
- Navigate to API Keys
- Copy the correct key
-
Check environment variable:
-
Test connection:
Pinecone Issues
Error: “Index not found”
Symptoms:- “Index ‘xyz’ not found”
- Cannot connect to Pinecone index
Verify index exists
Verify index exists
- Go to Pinecone Console
- Check if your index is listed
- Verify the index name matches your
PINECONE_INDEXenvironment variable
Check index name
Check index name
Create index if missing
Create index if missing
Create a new index in Pinecone Console with:
- Dimensions: 1536
- Metric: cosine
- Cloud: AWS (us-east-1 recommended for free tier)
Wait for index initialization
Wait for index initialization
New indexes take 30-60 seconds to become ready. Wait and try again.
Error: “Incorrect dimensions”
Symptoms:- “Dimension mismatch: expected X, got 1536”
- Embedding dimension errors
Check current index dimensions
In Pinecone Console, view your index details to see its dimension setting
Error: “Rate limit exceeded” (Pinecone)
Cause: Too many requests to Pinecone API Solutions:Ingestion Problems
Documents not found
Symptoms:- “ENOENT: no such file or directory”
- Files not being ingested
Check file paths
Check file paths
Paths are relative to where you run the script:Use absolute paths if unsure:
Verify files exist
Verify files exist
Check file permissions
Check file permissions
Supported file types only
Supported file types only
Only
.txt, .md, and .pdf files are processedOther file types are silently skippedPDF parsing fails
Symptoms:- Error: “Failed to parse PDF”
- Empty content from PDF files
- Scanned PDFs
- Password-Protected
- Corrupted Files
- Large Files
Problem: PDF contains images of text, not actual textTest: Try selecting text in a PDF viewer. If you can’t select text, it’s scannedSolutions:
- Use OCR software (Adobe Acrobat, Tesseract)
- Convert to text first
- Use a text-based PDF instead
Ingestion is very slow
Symptoms:- Takes many minutes to ingest documents
- Seems stuck during ingestion
| Cause | Solution |
|---|---|
| Many documents | Expected behavior - be patient |
| OpenAI rate limits | Upgrade tier or reduce chunk size |
| Large files | Increase chunk size to reduce chunks |
| Network issues | Check internet connection |
Query Issues
Always returns “I don’t know”
Symptoms:- Every question returns “I don’t know based on the uploaded files”
- No relevant answers found
Inconsistent or wrong answers
Symptoms:- Answers change between identical questions
- Answers don’t match document content
- Contradictory information
Increase topK for more context
Increase topK for more context
Check chunk size
Check chunk size
Chunks might be too small and missing context:
Use better model
Use better model
Remove ambiguous documents
Remove ambiguous documents
If you have contradictory information in different documents, the AI might use bothClean up your document set for consistency
Slow response times
Symptoms:- Questions take more than 5 seconds
- Timeout errors
Memory Issues
Out of memory during ingestion
Symptoms:- “JavaScript heap out of memory”
- Process crashes during ingestion
Runtime Errors
Error: “Context window not found”
Symptom: When usinggetCtxWindow()
Cause: Context window was never created or wrong name used
Solution:
Error: “Rate limit exceeded” (OpenAI)
Symptoms:- “Rate limit reached for requests”
- 429 status code
Implement retry logic
Implement retry logic
Upgrade OpenAI tier
Upgrade OpenAI tier
Visit OpenAI Usage Limits to:
- Check your current tier
- View rate limits
- Upgrade to higher tier
Reduce request frequency
Reduce request frequency
- Implement request queuing
- Add delays between requests
- Cache common questions
Use smaller contexts
Use smaller contexts
Network errors
Symptoms:- “ECONNREFUSED”
- “Network request failed”
- Timeout errors
- Check internet connection
- Verify firewall settings (ports 443 for HTTPS)
- Check proxy settings if behind corporate proxy:
- Retry with exponential backoff (see above)
Environment Issues
.env file not loaded
Symptoms:- Environment variables are undefined
- “API key not set” errors
Different behavior in production
Common issues:Environment variables not set
Environment variables not set
Set env vars in your deployment platform:
- Vercel: Environment Variables settings
- Heroku: Config Vars
- AWS: Parameter Store or Secrets Manager
- Docker: Pass via
-eflag or.envfile
File paths different
File paths different
Use absolute paths or path resolution:
Memory limits
Memory limits
Production environments often have stricter memory limitsConfigure appropriately for your platform
Still Stuck?
If you’re still experiencing issues:GitHub Issues
Search existing issues or create a new one
FAQ
Check frequently asked questions
Examples
See working code examples
Best Practices
Follow recommended patterns
- Node.js version (
node --version) - Package version (
npm list context-window) - Error message and stack trace
- Minimal code to reproduce the issue
- Operating system