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
Verify API key format
sk-Test API key
Check .env file
Verify environment loading
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
- Dimensions: 1536
- Metric: cosine
- Cloud: AWS (us-east-1 recommended for free tier)
Wait for index initialization
Wait for index initialization
Error: “Incorrect dimensions”
Symptoms:- “Dimension mismatch: expected X, got 1536”
- Embedding dimension errors
Verify required dimensions
text-embedding-3-small produces 1536-dimensional vectorsCheck current index dimensions
Recreate index with correct dimensions
- Delete the incorrectly configured index
- Create a new index with 1536 dimensions
- Re-run your ingestion
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
Verify files exist
Verify files exist
Check file permissions
Check file permissions
Supported file types only
Supported file types 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
- 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
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
Verify ingestion succeeded
createCtxWindow() for errorsRemove score threshold
Increase retrieval
Rephrase question
Check namespace
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
Use better model
Use better model
Remove ambiguous documents
Remove ambiguous documents
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
Increase Node.js memory
Process files in batches
Increase chunk size
Split large files
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
- 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
- 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
Memory limits
Memory limits
Still Stuck?
If you’re still experiencing issues:GitHub Issues
FAQ
Examples
Best Practices
- Node.js version (
node --version) - Package version (
npm list context-window) - Error message and stack trace
- Minimal code to reproduce the issue
- Operating system