An unusual Laravel error
I encountered a rather bamboozling error today that took me about 10 minutes to figure out and had me really perplexed. I’ve been using Laravel since 2012 and this was the first time I’d encountered this particular error.
I was working on developing a web application for a client and as I went to test some of the new features, the site threw an error. An icon that I had added to some notifications to make it easier for the users to scan a list of notifications could not be found. I found the page with the reference to the unreachable icon and changed it to something bog-standard that I knew was in heroicons. Still the error occurred. So I cleared the icon cache, cleared the view cache, cleared everything so the page would use the new icon that I had verified was available. Still the error occurred. No matter where I navigated to with in the web app, the error would be thrown and the error message still referred to the old icon.
I rebooted NGINX, I cleared all the caches again and I actually went into the cache folders and moved everything to the trash and emptied that. Still the error occurred. I did a project wide search of all the files, looking for any other references to this icon. The only reference was in the error logs. They couldn’t be throwing the error, but I still got rid of them. I rebooted the server again, rebooted the laptop, all desperate measures; the kind of steps you take when you know it’s unlikely to help, but there’s no real harm in trying and if it does work, you’re really none the wiser as to why.
Then it dawned on me. The error was thrown on every page I visited because of the database notifications I had just implemented. The first time the error was thrown, a model was being created and the notification I had set up for the post creation was triggered. These notifications are saved in the database along with the configuration of how to display the notification including the icon to be used. As I visited each page, the app attempted to show me the notification using the missing icon and the code that formats the notification kept choking. I had literally persisted the error.