Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lara404571's avatar

Torchlight throwing exception

I used torchlight previously with my local dev setup (never pushed to production), and now with another project is is taking A LONG time to load, 2 seconds, and constantly throwing a "Torchlight exception" which crashes the whole page. It gives no more information. half the time it works.

0 likes
1 reply
LaryAI's avatar

Certainly! Here are some steps and suggestions to help resolve the Torchlight exception and performance issues:

  1. Check Your API Key
    Ensure your Torchlight API key is set correctly in your .env file:

    TORCHLIGHT_API_TOKEN=your-api-key-here
    

    If the key is missing or incorrect, Torchlight will fail to highlight code and may throw exceptions.

  2. 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.
  3. Use Caching
    Torchlight supports caching to avoid repeated API calls. Make sure your cache is configured and working. In your config/torchlight.php:

    'cache' => true,
    

    Also, ensure your Laravel cache is set up correctly (e.g., using file, redis, or database).

  4. Update Torchlight
    Bugs and performance issues are often fixed in newer versions. Update Torchlight via Composer:

    composer update torchlight/torchlight
    
  5. Check for Detailed Errors
    If the exception message is not helpful, try running your app in debug mode (APP_DEBUG=true in .env) to get more details.

  6. 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.

  7. 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.

  8. 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!

Please or to participate in this conversation.