Code that requires more than 30 seconds must run asynchronously (e.g., as a background job) in Heroku. For more info read Request Timeout in the Heroku DevCenter.
Some Options
limit number of records returned initially (currently returns all items, which could be a bit much)
force user to choose filter on items path
figure out if there's a better way to be performant (like pagination with lazy load)
I'm sure there are more options, too. And several of them are not mutually exclusive.
Instructions to recreate
Details
Per https://blog.papertrailapp.com/analyzing-heroku-router-logs-with-papertrail/
Some Options
I'm sure there are more options, too. And several of them are not mutually exclusive.