Certainly! Here are some steps and suggestions to help resolve the Torchlight exception and performance issues:
-
Check Your API Key
Ensure your Torchlight API key is set correctly in your.envfile:TORCHLIGHT_API_TOKEN=your-api-key-hereIf the key is missing or incorrect, Torchlight will fail to highlight code and may throw exceptions.
-
Network Issues
Torchlight sends code to an external API for highlighting. If your network is slow or unstable, requests may time out or fail. Try:- Testing your internet connection.
- Whitelisting the Torchlight API endpoint if you have a firewall or VPN.
-
Use Caching
Torchlight supports caching to avoid repeated API calls. Make sure your cache is configured and working. In yourconfig/torchlight.php:'cache' => true,Also, ensure your Laravel cache is set up correctly (e.g., using
file,redis, ordatabase). -
Update Torchlight
Bugs and performance issues are often fixed in newer versions. Update Torchlight via Composer:composer update torchlight/torchlight -
Check for Detailed Errors
If the exception message is not helpful, try running your app in debug mode (APP_DEBUG=truein.env) to get more details. -
Fallback on Failure
You can configure Torchlight to fail gracefully by updating your config:'throw_errors' => false,This will prevent exceptions from crashing your page.
-
Check for Rate Limiting
If you’re making many requests (especially in development), you might be hitting the Torchlight API rate limits. Check your API dashboard or try reducing the number of requests. -
Clear Cache
Sometimes stale cache can cause issues. Clear your Laravel cache:php artisan cache:clear
Example config/torchlight.php settings:
return [
'token' => env('TORCHLIGHT_API_TOKEN'),
'cache' => true,
'throw_errors' => false,
];
If you continue to have issues, consider reaching out to Torchlight support with details about your setup and error messages.
Let me know if you need more help!