Hey guys, so I’ve spent about 24 hours trying to debug my Heroku app (which is a take on the bear classifier). Here is my GitHub repository: BMW_Classifier. Here is my web app: BMW_Heroku.
Opening up my web app, I get an Application Error which points me to go to my logs. When I go there, here’s what I get:
2021-12-24T12:19:35.066144+00:00 heroku[web.1]: Restarting
2021-12-24T12:19:52.747299+00:00 heroku[web.1]: Starting process with command voila --port=42273 --no-browser --enable_nbextensions=True BMW_App.ipynb
2021-12-24T12:19:53.775262+00:00 heroku[web.1]: Starting process with command voila --port=55607 --no-browser --enable_nbextensions=True BMW_App.ipynb
2021-12-24T12:19:54.359020+00:00 app[web.1]: [Voila] Using /tmp to store connection files
2021-12-24T12:19:54.359347+00:00 app[web.1]: [Voila] Storing connection files in /tmp/voila_x6e378w5.
2021-12-24T12:19:54.359399+00:00 app[web.1]: [Voila] Serving static files from /app/.heroku/python/lib/python3.9/site-packages/voila/static.
2021-12-24T12:19:55.102661+00:00 app[web.1]: [Voila] Voilà is running at:
2021-12-24T12:19:55.102668+00:00 app[web.1]: http://localhost:42273/
2021-12-24T12:19:55.554237+00:00 app[web.1]: [Voila] Using /tmp to store connection files
2021-12-24T12:19:55.554574+00:00 app[web.1]: [Voila] Storing connection files in /tmp/voila_ke227i51.
2021-12-24T12:19:55.554624+00:00 app[web.1]: [Voila] Serving static files from /app/.heroku/python/lib/python3.9/site-packages/voila/static.
2021-12-24T12:19:56.380512+00:00 app[web.1]: [Voila] Voilà is running at:
2021-12-24T12:19:56.380519+00:00 app[web.1]: http://localhost:55607/
2021-12-24T12:20:39.000000+00:00 app[api]: Build succeeded
2021-12-24T12:20:42.600145+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2021-12-24T12:20:42.664934+00:00 app[web.1]: [Voila] Handle signal 15.
2021-12-24T12:20:42.872497+00:00 heroku[web.1]: Process exited with status 0
2021-12-24T12:20:54.249772+00:00 heroku[web.1]: Error R10 (Boot timeout) → Web process failed to bind to $PORT within 60 seconds of launch
2021-12-24T12:20:54.318676+00:00 heroku[web.1]: Stopping process with SIGKILL
2021-12-24T12:20:54.543197+00:00 heroku[web.1]: Process exited with status 137
2021-12-24T12:20:54.605706+00:00 heroku[web.1]: State changed from starting to crashed
2021-12-24T12:20:57.722867+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/" host=bmwapp.herokuapp.com request_id=fb5e8980-2b1c-4832-8063-53b41a6e809c fwd=“89.36.78.141” dyno= connect= service= status=503 bytes= protocol=https
2021-12-24T12:20:58.231893+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/favicon.ico" host=bmwapp.herokuapp.com request_id=3f14c61c-6ee2-443a-a265-3f34f0513f88 fwd=“89.36.78.141” dyno= connect= service= status=503 bytes= protocol=https
There is an Error R10 (Boot timeout) happening for whatever reason. I tried extending my boot time from 60s all the way to 180s and still I get the same errors.
I’ve even gone as far as copying almost everything from another git user’s repository. No luck. I keep running into the same problem.
Alright, so I said screw it with Heroku and switch over to mybinder. After some tinkering I managed to get the app to spit out an error message (I believe this is what was causing Heroku to bug out as well).
Here it is:
UnpicklingError Traceback (most recent call last)
/tmp/ipykernel_49/375279062.py in <module>
1 # path = Path()
----> 2 learn_inf = load_learner('export.pkl')
/srv/conda/envs/notebook/lib/python3.7/site-packages/fastai/learner.py in load_learner(fname, cpu, pickle_module)
382 "Load a `Learner` object in `fname`, optionally putting it on the `cpu`"
383 distrib_barrier()
--> 384 res = torch.load(fname, map_location='cpu' if cpu else None, pickle_module=pickle_module)
385 if hasattr(res, 'to_fp32'): res = res.to_fp32()
386 if cpu: res.dls.cpu()
/srv/conda/envs/notebook/lib/python3.7/site-packages/torch/serialization.py in load(f, map_location, pickle_module, **pickle_load_args)
606 return torch.jit.load(opened_file)
607 return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
--> 608 return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
609
610
/srv/conda/envs/notebook/lib/python3.7/site-packages/torch/serialization.py in _legacy_load(f, map_location, pickle_module, **pickle_load_args)
775 "functionality.")
776
--> 777 magic_number = pickle_module.load(f, **pickle_load_args)
778 if magic_number != MAGIC_NUMBER:
779 raise RuntimeError("Invalid magic number; corrupt file?")
UnpicklingError: invalid load key, 'v'.
After looking around on the web, it seems that this may stem from an issue of me using git lfs for my export.pkl file. I have no idea why binder doesn’t work properly with git lfs since I’ve got very little web dev experience, but I’ll continue looking.
Found the issue. I accidentally deleted my .gitattributes folder in order to match someone else’s repo. I learned that the .gitattributes directory is essential for git lfs. In order to solve the issue I deleted the export.pkl file within my repo and uploaded it back with git lfs, this time making sure to track the .gitattributes directory as well.
Hey, as you can see, your logs say H20 and Error R10 (Boot timeout) → Web process failed to bind to $PORT within 60 seconds of launch
You also seem to launch on port 6752 which is probably hardcoded rather than the one Heroku is giving you through the PORT environment variable. I would simply advise to change to the env var and it should be fine
It looks like it times out because of Heroku expects viola to start within 60 sec. Here is I tried again:
2022-03-05T09:24:27.000000+00:00 app[api]: Build succeeded
2022-03-05T09:24:33.240682+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2022-03-05T09:24:33.311230+00:00 heroku[web.1]: Stopping process with SIGKILL
2022-03-05T09:24:33.463444+00:00 heroku[web.1]: Process exited with status 137
2022-03-05T09:24:33.541220+00:00 heroku[web.1]: State changed from starting to crashed
2022-03-05T09:24:33.545263+00:00 heroku[web.1]: State changed from crashed to starting
2022-03-05T09:24:54.087733+00:00 heroku[web.1]: Starting process with command `voila --port=50953 --no-browser --enable_nbextensions=True sea_animals_classifier.ipynb`
2022-03-05T09:24:56.613828+00:00 app[web.1]: [Voila] Using /tmp to store connection files
2022-03-05T09:24:56.614230+00:00 app[web.1]: [Voila] Storing connection files in /tmp/voila_ldtoufrh.
2022-03-05T09:24:56.614276+00:00 app[web.1]: [Voila] Serving static files from /app/.heroku/python/lib/python3.9/site-packages/voila/static.
2022-03-05T09:24:57.448978+00:00 app[web.1]: [Voila] Voilà is running at:
2022-03-05T09:24:57.448999+00:00 app[web.1]: http://localhost:50953/
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2022-03-05T09:24:33.311230+00:00 heroku[web.1]: Stopping process with SIGKILL
2022-03-05T09:24:33.463444+00:00 heroku[web.1]: Process exited with status 137
2022-03-05T09:24:33.541220+00:00 heroku[web.1]: State changed from starting to crashed
2022-03-05T09:24:33.545263+00:00 heroku[web.1]: State changed from crashed to starting
2022-03-05T09:24:54.087733+00:00 heroku[web.1]: Starting process with command `voila --port=50953 --no-browser --enable_nbextensions=True sea_animals_classifier.ipynb`
2022-03-05T09:24:56.613828+00:00 app[web.1]: [Voila] Using /tmp to store connection files
2022-03-05T09:24:56.614230+00:00 app[web.1]: [Voila] Storing connection files in /tmp/voila_ldtoufrh.
2022-03-05T09:24:56.614276+00:00 app[web.1]: [Voila] Serving static files from /app/.heroku/python/lib/python3.9/site-packages/voila/static.
2022-03-05T09:24:57.448978+00:00 app[web.1]: [Voila] Voilà is running at:
2022-03-05T09:24:57.448999+00:00 app[web.1]: http://localhost:50953/
2022-03-05T09:25:55.007064+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2022-03-05T09:25:55.491556+00:00 heroku[web.1]: Stopping process with SIGKILL
2022-03-05T09:25:55.677512+00:00 heroku[web.1]: Process exited with status 137
2022-03-05T09:25:55.774246+00:00 heroku[web.1]: State changed from starting to crashed
2022-03-05T09:25:58.147192+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=sea-animals-classifier.herokuapp.com request_id=6a613c49-2b6a-41d6-b348-0f81b622f94f fwd="194.110.114.251" dyno= connect= service= status=503 bytes= protocol=https
From 0.3.0, Voila will not listen on all interfaces by default (#926) for security reasons. In the case of Heroku, you need to add --Voila.ip=0.0.0.0 to your command in the Procfile to make it works.
Have a good day!