Troubleshooting Guide¶
This guide helps you diagnose and resolve common issues when developing with INFINITY.JS. Issues are organized by category with symptoms, causes, and solutions.
Quick Diagnostic Checklist¶
Before diving into specific issues, run through this quick checklist:
- Is INFINITY.JS running the latest version?
- Are all required modules loaded with
infinity.loadModule()? - Are file paths relative to the main program folder?
- Is the console output showing any error messages?
- Have you checked file permissions?
- Is there enough disk space and memory?
- Are ports available (not used by other processes)?
Installation and Setup Issues¶
Runtime Won't Start¶
Symptoms: - Double-clicking infinity.exe does nothing - Process starts and immediately exits - No console output
Causes & Solutions:
-
Missing dependencies (Windows):
Solution: Install the Visual C++ Redistributable (# Check for missing DLLs dumpbin /dependents infinity.exeredist/vc_redist.x64.exein the release archive). Make sure that the DLLs shipped inwin-x64(e.g.libmujs.dll, OpenSSL 3libcrypto-3-x64.dllandlibssl-3-x64.dll,pdfium.dll,freeimage.dll) are next toinfinity.exe. If OpenSSL cannot be loaded, the runtime stops at startup withFailed to load OpenSSL 3 (libcrypto, libssl) from <folder>; on Linuxlibcrypto.so.3andlibssl.so.3must be next toinfinity. -
Permission denied (Linux):
Solution:# Error: Permission deniedcd bin/linux-x64 chmod +x infinity ./infinity -console ../my-app/js/main.js -
Missing console flag:
Solution:# No output visible - output only goes to the log file in the logs folder infinity.exe ../my-app/js/main.jsinfinity.exe -console ../my-app/js/main.js # Shows console output -
Wrong script path: A relative script path is resolved against the folder of the executable, not against the current directory of your shell. The script is the first argument that ends in
.js. If no script is found, the runtime printsInvalid script file parameter for execution. -
Nothing logged: Console output is filtered by
MinLogLevelininfinity.ini(0shows everything includingconsole.log(),1hidesconsole.log()).
Module Not Found¶
Symptoms:
Module infinity.xyz not found
Cause: Module name typo, a namespace that is not a module, or a native extension that could not be loaded.
Solution:
// Correct module names (case-sensitive)
infinity.loadModule('infinity.http'); // Correct
infinity.loadModule('infinity.HTTP'); // WRONG - case matters
infinity.loadModule('http'); // WRONG - needs full name
infinity.loadModule('infinity.file'); // WRONG - infinity.file is part of 'infinity.fileSystem'
infinity.loadModule('infinity.event'); // WRONG - always available, not a module
Run infinity -listModules to list the available modules, or check the module table in the API reference.
Script File Not Found¶
Symptoms:
Error loading source file ...services/user.js: ...
Causes & Solutions:
-
Wrong relative path:
// Paths are relative to main program folder, not current file infinity.include('services/user.js'); // Correct infinity.include('../services/user.js'); // WRONG if already in root -
TypeScript not compiled:
# TypeScript files must be compiled to JavaScript first cd your-project tsc # Compile TypeScript to JavaScript -
File extension required:
infinity.include('services/user.js'); // Correct infinity.include('services/user'); // WRONG - extension required
HTTP Server Issues¶
Port Already in Use¶
Symptoms: - Starting the server fails because the port is already used by another process
Diagnosis:
# Windows
netstat -ano | findstr :8080
# Linux
ss -tlnp | grep :8080
Solutions:
-
Stop the existing process:
# Windows (replace PID with actual process ID) taskkill /PID 12345 /F # Linux kill 12345 -
Use different port:
let server = new infinity.http.server(false, false, false, false, false, 8081); -
Ports below 1024 on Linux:
- Ports like 80 and 443 need root privileges or the capability
CAP_NET_BIND_SERVICE(e.g.AmbientCapabilities=CAP_NET_BIND_SERVICEin the systemd unit), or use a reverse proxy
SSL/TLS Certificate Errors¶
Symptoms:
Error: SSL handshake failed
Solutions:
-
Certificate file not found: With
ssl = true, the server uses the test certificateresources/infinity.crtandresources/infinity.keyby default. Set your own certificate withsetCertificate(). Missing files are silently ignored, so check the paths:let certFile = infinity.current.root + '../ssl/cert.pem'; let keyFile = infinity.current.root + '../ssl/key.pem'; infinity.loadModule('infinity.fileSystem'); console.info(certFile + ': ' + infinity.file.exists(certFile)); console.info(keyFile + ': ' + infinity.file.exists(keyFile)); server.setCertificate(certFile, keyFile); -
Certificate format issues:
- Ensure certificates are in PEM format
-
Verify certificate chain is complete
-
Client certificates:
let server = new infinity.http.server( true, // ssl false, // verifyCertificate - true requires client certificates (mutual TLS) false, false, false, 443 );
verifyCertificate doesn't disable anything for self-signed server certificates - it requests and verifies client certificates against a root certificate. Leave it false unless your clients authenticate with certificates.
High Latency / Slow Responses¶
Symptoms: - Requests taking > 1 second - Slow request warnings in logs - Poor load test results
Diagnosis:
// Enable slow request logging
let server = new infinity.http.server(
false, false, false, false, true,
8080, 2048, 64, 1024 * 1024,
0.5 // slowRequestTime - log requests > 500ms
);
Solutions:
-
Thread pool too small:
// Before: poolSize = 8 let server = new infinity.http.server(false, false, false, false, false, 8080, 2048, 8); // After: Increase to match workload let server = new infinity.http.server(false, false, false, false, false, 8080, 2048, 32); // 4× more threads -
Database not using connection pooling:
// Enable pooling (set before connect) db.pooling = true; db.minPoolSize = 5; db.maxPoolSize = 20; db.connect(infinity.database.provider.mysql, 'localhost', 3306, 'mydb', 'user', 'pass'); -
Not using transactions for batch operations:
// Slow: one transaction per statement for (let i = 0; i < 1000; i++) { db.execute('INSERT INTO ...'); } // Fast: Use one transaction db.startTransaction(); for (let i = 0; i < 1000; i++) { db.execute('INSERT INTO ...'); } db.commit(); -
Compression overhead:
// Disable compression if CPU-bound let server = new infinity.http.server(false, false, false, false, // compress = false false, 8080);
Connection Refused / Cannot Connect¶
Symptoms:
Error: Connection refused
Error: ECONNREFUSED
Solutions:
-
Server not started:
server.start(); // Don't forget to call start()! while (!infinity.terminated) { infinity.event.processQueue(); infinity.sleep(25); } -
Main program ended: If the main script reaches its end, the runtime terminates and the server stops. Keep the main program in a loop until
infinity.terminatedistrue. -
Firewall blocking:
# Windows: Allow through firewall netsh advfirewall firewall add rule name="INFINITY.JS" dir=in action=allow protocol=TCP localport=8080 # Linux: Check firewall sudo ufw status sudo ufw allow 8080/tcp
Memory Leaks / Growing Memory Usage¶
Symptoms: - Memory usage constantly increasing - Server slows down over time - Out of memory errors after hours/days
Diagnosis:
// Monitor memory usage in the main loop (there is no setInterval in INFINITY.JS)
let lastCheck = 0;
while (!infinity.terminated) {
if (Date.now() - lastCheck >= 60000) {
lastCheck = Date.now();
console.info('Process memory: ' + Math.round(infinity.os.processMemory / 1048576) + ' MB');
}
infinity.event.processQueue();
infinity.sleep(25);
}
Solutions:
-
Objects not freed:
// Always free objects with free() method let db = new infinity.database(); try { // Use database } finally { db.free(); // Critical: release resources } -
Accumulating data in shared memory or long-running scripts:
infinity.loadModule('infinity.memory'); // Bad: Entries are never removed infinity.memory.putString('cache', 'user:1', 'John'); // Good: Let entries expire (here after 300 seconds) and limit the namespace infinity.memory.putString('cache', 'user:1', 'John', 300); infinity.memory.setMaxCount('cache', 1000); // Expired entries are only removed by flushExpired() - call it regularly (e.g. in a thread) infinity.memory.flushExpired('cache');
Arrays and objects in the main program or in threads that keep growing (e.g. a cache in a long-running loop) need a size limit as well.
- Event handlers not unregistered:
// Register handler infinity.event.register('myEvent', callback); // Unregister when done infinity.event.unregister('myEvent');
Database Issues¶
Connection Failed¶
Symptoms:
Error: Cannot connect to database
Error: Access denied for user
Error: Unknown database
Solutions:
-
SQLite - File not found or no permissions:
db.specificOptions['Direct'] = true; db.specificOptions['ForceCreateDatabase'] = true; // Create if not exists let dbPath = infinity.current.root + '../database.db'; console.info('Database path: ' + dbPath); // Verify path db.connect(infinity.database.provider.sqlite, '', 0, dbPath); -
MySQL/PostgreSQL - Wrong credentials:
// Check connection parameters db.connect( infinity.database.provider.mysql, 'localhost', // server 3306, // port 'mydb', // database name 'username', // username 'password' // password ); -
MySQL - Server not running:
# Windows net start MySQL80 # Linux sudo systemctl start mysql sudo systemctl status mysql -
PostgreSQL - Authentication failed:
# Check pg_hba.conf for authentication settings # Linux: /etc/postgresql/*/main/pg_hba.conf # Windows: C:\Program Files\PostgreSQL\*\data\pg_hba.conf
Slow Queries¶
Symptoms: - Queries taking seconds instead of milliseconds - Database operations blocking server threads
Diagnosis:
// Time queries
let start = Date.now();
db.execute('SELECT * FROM large_table WHERE ...');
console.info('Query time: ' + (Date.now() - start) + 'ms');
Solutions:
-
Missing indexes:
// Add indexes to frequently queried columns db.execute('CREATE INDEX idx_user_email ON users(email)'); db.execute('CREATE INDEX idx_order_date ON orders(created_at)'); // Check query plan (SQLite) db.execute('EXPLAIN QUERY PLAN SELECT * FROM users WHERE email = ?'); -
Not using parameterized queries:
// Slow: String concatenation, no query plan caching db.execute('SELECT * FROM users WHERE id = ' + userId); // Fast: Parameterized, enables caching db.sql = 'SELECT * FROM users WHERE id = :id'; db.setParamValue('id', userId); db.execute(); -
Large result sets:
// Limit results db.sql = 'SELECT * FROM large_table LIMIT 100 OFFSET :offset'; db.setParamValue('offset', page * 100); db.execute();
Transaction Deadlocks¶
Symptoms:
Error: Lock wait timeout exceeded
Error: Deadlock detected
Solutions:
-
Keep transactions short:
// Bad: Long-running transaction db.startTransaction(); // ... lots of processing ... db.commit(); // Good: Short transaction // ... do processing first ... db.startTransaction(); db.execute('UPDATE ...'); db.execute('INSERT ...'); db.commit(); -
Consistent lock ordering:
// Always lock resources in same order // Good: Always lock users before orders db.execute('SELECT * FROM users WHERE id = ? FOR UPDATE'); db.execute('SELECT * FROM orders WHERE user_id = ? FOR UPDATE'); -
Use appropriate isolation level:
db.startTransaction(infinity.database.isolationLevel.readCommitted); // ... operations ... db.commit();
Character Encoding Issues¶
Symptoms: - Special characters appear as ? or garbled - Emoji not displaying correctly
Solutions:
-
Set database encoding:
// MySQL db.specificOptions['Charset'] = 'utf8mb4'; // Supports emoji db.specificOptions['UseUnicode'] = true; // SQLite db.execute('PRAGMA encoding = "UTF-8"'); -
Connection encoding:
// PostgreSQL db.specificOptions['Charset'] = 'UTF8'; db.specificOptions['UseUnicode'] = true;
Multi-threading Issues¶
Thread Won't Terminate¶
Symptoms: - thread.stop() called but thread keeps running - Application hangs on exit
Cause: Thread not checking infinity.threadTerminated flag. thread.stop() waits until the thread script has finished, so the main program hangs as long as the thread keeps running.
Solution:
// main.js
infinity.loadModule('infinity.thread');
let thread = new infinity.thread('worker.js');
thread.start();
// Later...
thread.stop(); // Sets infinity.threadTerminated = true in thread and waits for it
// worker.js - MUST check flag regularly
while (!infinity.terminated && !infinity.threadTerminated) { // Check flags!
// Do work
infinity.sleep(100); // Don't sleep too long
}
Prevention:
// Bad: Thread never checks flag
while (true) { // WRONG - will never terminate
// Work
}
// Good: Regular checks
while (!infinity.threadTerminated) {
// Work
infinity.sleep(100); // Check every 100ms
}
Race Conditions¶
Symptoms: - Inconsistent results between runs - Data corruption - Occasional crashes
Solutions:
-
Use shared memory for synchronization:
infinity.loadModule('infinity.memory'); // Thread 1: Write infinity.memory.putNumber('counters', 'requests', count); // Thread 2: Read let count = infinity.memory.getNumber('counters', 'requests'); -
Use locks for critical sections:
// infinity.lock is always available (no loadModule needed) infinity.lock.beginWrite('myResource'); try { // Critical section - only one thread at a time let value = infinity.memory.getNumber('state', 'counter'); value++; infinity.memory.putNumber('state', 'counter', value); } finally { infinity.lock.endWrite('myResource'); } // For a simple counter, the atomic operation is enough: infinity.memory.increment('state', 'counter', 1); -
Use event system for communication:
// Thread 1: Send event infinity.event.send('dataReady', { id: 123, data: 'test' }); // Thread 2: Receive event infinity.event.register('dataReady', (params: any): void => { console.info('Data received: ' + JSON.stringify(params)); }); while (!infinity.terminated && !infinity.threadTerminated) { infinity.event.processQueue(); // Process events infinity.sleep(25); }
Deadlock¶
Symptoms: - Application hangs - No CPU activity - Threads waiting indefinitely
Solution:
infinity.lock.beginRead() and beginWrite() wait until the lock is available - there is no timeout.
-
Always release locks:
infinity.lock.beginWrite('resource1'); try { // Use resource } finally { infinity.lock.endWrite('resource1'); // Also released if an exception occurs } -
Don't nest locks with the same name: Calling
beginWrite()again for a lock that the same script already holds can block forever (under Windows the locks are not reentrant). -
Consistent lock ordering:
// Always acquire locks in same order across all threads // Good: Always lock A before B infinity.lock.beginWrite('resourceA'); infinity.lock.beginWrite('resourceB'); try { // Use resources } finally { infinity.lock.endWrite('resourceB'); infinity.lock.endWrite('resourceA'); }
Vector Database Issues¶
Out of Memory¶
Symptoms:
Error: Out of memory
Error: Cannot allocate vector space
Cause: Vector database memory usage exceeds available RAM.
The parameters of infinity.vectordb.open() are: namespace, dimensions, maxItems, parallelSearchThreads, compactThreshold, normalize, deleteStrategy, ivfEnabled, ivfNumClusters, ivfNProbe (see infinity.vectordb).
Solutions:
-
Calculate memory requirements:
// Vectors are stored as 32-bit floats: // memory per vector ≈ dimensions × 4 bytes (plus index overhead) // 384 dimensions: ≈ 1.5 KB per vector, 1M vectors ≈ 1.5 GB -
Limit the number of items:
// maxItems limits the namespace - when it is reached, // deleteStrategy decides which item is removed infinity.vectordb.open('index', 384, 100000, 2, 0.3, true, infinity.vectordb.deleteStrategy.firstId, true, 316, 10); -
Reduce vector dimensions: Use an embedding model with fewer dimensions (e.g. 384 instead of 1536) - memory grows linearly with the dimensions.
Poor Search Accuracy / Low Recall¶
Symptoms: - Expected results missing in the search result
Solutions:
-
Search more IVF clusters:
// ivfNProbe: number of clusters searched per query (higher = more accurate, slower) infinity.vectordb.open('index', 384, 100000, 2, 0.3, true, infinity.vectordb.deleteStrategy.firstId, true, 316, 30); -
Disable IVF for small datasets:
// ivfEnabled = false: exact search over all vectors infinity.vectordb.open('index', 384, 10000, 2, 0.3, true, infinity.vectordb.deleteStrategy.firstId, false, 0, 0); -
Check the similarity threshold:
infinity.vectordb.search(namespace, vector, threshold, maxResults)only returns results with a similarity abovethreshold. Lower the threshold if relevant results are missing.
Slow Vector Search¶
Symptoms: - High search latency - Low queries per second
Solutions:
-
Enable IVF for large datasets:
// ivfNumClusters ≈ sqrt(maxItems), ivfNProbe ≈ 1-10 % of the clusters infinity.vectordb.open('index', 384, 1000000, 4, 0.3, true, infinity.vectordb.deleteStrategy.firstId, true, 1000, 20); -
Use more search threads: Increase
parallelSearchThreads(typically 1-4) if CPU cores are available. -
Reduce vector dimensions: Fewer dimensions mean less work per comparison.
Performance Issues¶
High CPU Usage¶
Symptoms: - CPU at 100% constantly - System unresponsive
Diagnosis:
# Windows
wmic path win32_perfformatteddata_perfproc_process get Name,PercentProcessorTime | findstr infinity
# Linux
top -p $(pgrep infinity)
Solutions:
-
Too many threads:
// Reduce thread count to match CPU cores let cpuCores = 8; let server = new infinity.http.server(false, false, false, false, false, 8080, 2048, cpuCores); // Don't exceed cores for CPU-bound work -
Compression overhead:
// Disable compression if CPU-bound let server = new infinity.http.server(false, false, false, false, // compress = false false, 8080); -
Infinite loops in threads:
// Bad: Busy-wait (100% CPU) while (!infinity.threadTerminated) { // No sleep - spins at 100% CPU! } // Good: Sleep between iterations while (!infinity.threadTerminated) { // Work infinity.sleep(25); // Yield CPU }
High Memory Usage¶
Symptoms: - Memory usage in GB range - Out of memory errors - System swapping
Diagnosis:
// infinity.os is always available
console.info('Process memory: ' + Math.round(infinity.os.processMemory / 1048576) + ' MB');
console.info('Free system memory: ' + Math.round(infinity.os.memoryFree / 1048576) + ' MB');
Solutions:
-
Free database objects:
let db = new infinity.database(); try { // Use database } finally { db.free(); // Release immediately } -
Limit cache sizes:
const MAX_CACHE = 1000; if (cache.length > MAX_CACHE) { cache = cache.slice(-MAX_CACHE); // Keep only recent } -
Stream large responses:
// Don't load the entire file into a string - // let the server send the file from disk infinity.http.response.contentType = 'application/zip'; infinity.http.response.contentFilename = infinity.current.root + '../files/large-file.zip';
Common JavaScript Errors¶
Type Error¶
Symptoms:
TypeError: Cannot read property 'x' of undefined
TypeError: xxx is not a function
Solutions:
-
Check for undefined:
// Bad let value = user.address.city; // Error if address is undefined // Good let value = user && user.address ? user.address.city : 'Unknown'; // Or use optional chaining in TypeScript (compiled to ES5 by tsc) let value = user?.address?.city ?? 'Unknown'; -
Verify function exists:
if (typeof myFunction === 'function') { myFunction(); } else { console.error('myFunction is not defined'); }
Module Loading Order¶
Symptoms: - A TypeError when accessing e.g. infinity.http.server - the namespace infinity.http is undefined
Cause: Accessing module before loading.
Solution:
// Load modules at start of file
infinity.loadModule('infinity.http');
infinity.loadModule('infinity.database');
// Now safe to use
let server = new infinity.http.server();
File Path Issues¶
Symptoms:
Error: File not found
Error: Cannot read file
Solutions:
- Use absolute paths:
// Relative to main program folder let configPath = infinity.current.root + '../config.ini'; console.info('Config path: ' + configPath); // Verify
Relative paths in file functions are resolved against the folder of the executable (the current directory of the process), not against your main program.
- Check file exists before reading:
infinity.loadModule('infinity.fileSystem'); let filePath = infinity.current.root + 'data.json'; if (infinity.file.exists(filePath)) { let content = infinity.file.readString(filePath, infinity.encoding.utf8); } else { console.error('File not found: ' + filePath); }
Getting Help¶
If you've tried the solutions above and still have issues:
1. Enable Detailed Logging¶
Set MinLogLevel=0 in the [LogFile] section of infinity.ini and start the runtime with -console. The log files are written to the logs folder next to the platform folders.
// Log all HTTP requests
infinity.loadModule('infinity.http');
let server = new infinity.http.server(false, false, false, false,
true, // accessLog = true
8080);
2. Collect Diagnostic Information¶
// System information
console.info('INFINITY.JS Version: ' + infinity.version); // Always include version!
// infinity.os is always available (no loadModule needed)
console.info('OS: ' + infinity.os.name);
console.info('CPU cores: ' + infinity.os.processorCount);
console.info('Root path: ' + infinity.current.root);
console.info('Temp path: ' + infinity.current.temp);
Important: Always include the infinity.version output when reporting issues. Different versions may have different behaviors or known issues.
3. Create Minimal Reproduction¶
Create the smallest possible code that reproduces the issue:
// Minimal reproduction example
infinity.loadModule('infinity.http');
let server = new infinity.http.server(false, false, false, false, false, 8080);
server.start();
console.info('Server started, press Ctrl+C to stop');
while (!infinity.terminated) {
infinity.event.processQueue();
infinity.sleep(25);
}
server.stop();
4. Check Documentation¶
- API Reference - Complete API documentation
- Performance Guide - Optimization tips
- Examples - Working code examples
5. Report Issues¶
If you've found a bug:
- Check existing issues
- Create new issue with:
- INFINITY.JS version (from
infinity.version) - REQUIRED - Operating system and version
- Minimal code reproduction
- Complete error messages
- Expected vs actual behavior
- Steps to reproduce
Example Issue Template:
**INFINITY.JS Version:** 3.21.316
**OS:** Windows 11 Pro (x64) / Ubuntu 24.04 (x64)
**Issue:** Server crashes on large POST requests
**Code to reproduce:**
[paste minimal code here]
**Error message:**
[paste complete error here]
**Expected:** Server should handle request
**Actual:** Server crashes with error
Prevention Tips¶
Code Quality¶
-
Always use try-finally for resources:
let db = new infinity.database(); try { // Use database } finally { db.free(); // Always freed, even if exception } -
Check infinity.terminated regularly:
while (!infinity.terminated) { // Work infinity.sleep(100); } -
Use parameterized queries:
db.sql = 'SELECT * FROM users WHERE id = :id'; db.setParamValue('id', userId); db.execute();
Development Practices¶
-
Enable strict mode:
'use strict'; -
Log important events:
console.info('Server started on port ' + port); console.info('Database connected: ' + dbPath); -
Validate inputs:
if (!username || username.length < 3) { throw 'Invalid username'; }
Production Deployment¶
-
Set appropriate limits:
let server = new infinity.http.server( true, false, false, false, true, 443, 2048, // maxConnections 64, // poolSize 10 * 1024 * 1024, // maxContentLength 2.0 // slowRequestTime ); -
Enable logging:
// Access log for monitoring let server = new infinity.http.server(false, false, false, false, true, // accessLog 8080); -
Monitor resource usage:
// e.g. every 5 minutes in the main loop or a scheduled task console.info('Process memory: ' + Math.round(infinity.os.processMemory / 1048576) + ' MB');
Quick Reference¶
| Issue | Quick Fix |
|---|---|
| Port in use | Use different port or kill process |
| Slow queries | Add indexes, use transactions |
| Thread won't stop | Check infinity.threadTerminated in loop |
| Memory leak | Call .free() on objects |
| High CPU | Reduce threads, add sleep() calls |
| Module not found | Check spelling, use full name, run infinity -listModules |
| No console output | Start with -console, set MinLogLevel=0 |
| File not found | Use infinity.current.root for absolute path |
| Connection refused | Call server.start() |
| Encoding issues | Set the Charset specific option (e.g. 'utf8mb4' for MySQL) |
| Deadlock | Always release locks in finally, consistent ordering |
For more detailed solutions, see the sections above.