Skip to main content

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
Solutions:
1

Verify API key format

OpenAI keys start with sk-
2

Test API key

If this fails, regenerate your key at OpenAI API Keys
3

Check .env file

Ensure no extra spaces or quotes:
4

Verify environment loading

Error: “Invalid API key” (Pinecone)

Solutions:
  1. Verify key in Pinecone Console:
  2. Check environment variable:
  3. Test connection:

Pinecone Issues

Error: “Index not found”

Symptoms:
  • “Index ‘xyz’ not found”
  • Cannot connect to Pinecone index
Solutions:
  1. Go to Pinecone Console
  2. Check if your index is listed
  3. Verify the index name matches your PINECONE_INDEX environment variable
Create a new index in Pinecone Console with:
  • Dimensions: 1536
  • Metric: cosine
  • Cloud: AWS (us-east-1 recommended for free tier)
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
Cause: Pinecone index was created with wrong dimensions Solution:
1

Verify required dimensions

OpenAI’s text-embedding-3-small produces 1536-dimensional vectors
2

Check current index dimensions

In Pinecone Console, view your index details to see its dimension setting
3

Recreate index with correct dimensions

  1. Delete the incorrectly configured index
  2. Create a new index with 1536 dimensions
  3. Re-run your ingestion
Deleting an index removes all stored vectors. Make sure you have your source documents to re-ingest.

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
Solutions:
Paths are relative to where you run the script:
Use absolute paths if unsure:
Only .txt, .md, and .pdf files are processedOther file types are silently skipped

PDF parsing fails

Symptoms:
  • Error: “Failed to parse PDF”
  • Empty content from PDF files
Solutions:
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
Causes & Solutions: Optimization tips:

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
Debugging steps:
1

Verify ingestion succeeded

Check console output during createCtxWindow() for errors
2

Remove score threshold

3

Increase retrieval

4

Rephrase question

Use terminology that appears in your documents:
5

Check namespace

Ensure you’re querying the correct namespace:

Inconsistent or wrong answers

Symptoms:
  • Answers change between identical questions
  • Answers don’t match document content
  • Contradictory information
Solutions:
Chunks might be too small and missing context:
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
Solutions:

Memory Issues

Out of memory during ingestion

Symptoms:
  • “JavaScript heap out of memory”
  • Process crashes during ingestion
Solutions:
1

Increase Node.js memory

2

Process files in batches

3

Increase chunk size

Fewer chunks = less memory:
4

Split large files

If you have very large PDFs or text files, split them into smaller files

Runtime Errors

Error: “Context window not found”

Symptom: When using getCtxWindow() 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
Solutions:
Visit OpenAI Usage Limits to:
  • Check your current tier
  • View rate limits
  • Upgrade to higher tier
  • Implement request queuing
  • Add delays between requests
  • Cache common questions

Network errors

Symptoms:
  • “ECONNREFUSED”
  • “Network request failed”
  • Timeout errors
Solutions:
  1. Check internet connection
  2. Verify firewall settings (ports 443 for HTTPS)
  3. Check proxy settings if behind corporate proxy:
  4. Retry with exponential backoff (see above)

Environment Issues

.env file not loaded

Symptoms:
  • Environment variables are undefined
  • “API key not set” errors
Solutions:

Different behavior in production

Common issues:
Set env vars in your deployment platform:
  • Vercel: Environment Variables settings
  • Heroku: Config Vars
  • AWS: Parameter Store or Secrets Manager
  • Docker: Pass via -e flag or .env file
Use absolute paths or path resolution:
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
When reporting issues, please include:
  • Node.js version (node --version)
  • Package version (npm list context-window)
  • Error message and stack trace
  • Minimal code to reproduce the issue
  • Operating system