getmango / Mango

Mango is a self-hosted manga server and web reader
https://getmango.app
MIT License
1.69k stars 120 forks source link

[Bug Report] Unexpected token: <EOF> at line 1, column 1 #295

Closed afknst closed 2 years ago

afknst commented 2 years ago

Describe the bug One day I suddenly got "HTTP 500: Internal server error. Please try again later." from the HOME and LIBRARY pages. And from terminal log: [ERROR] 2022/04/18 13:35:39 | Unexpected token: <EOF> at line 1, column 1

Then I tried to upgrade (from v0.26.0 to v0.26.2), to delete the database and regenerate, to recompile de docker image, nothing worked. I was thinking that a file in my library may be damaged. But the scanner works fine, I got the error only when I access the main page. So I don't know.

To Reproduce I don't know.

Expected behavior Functioning normally.

Environment (please complete the following information):

Docker (if you are running Mango in a Docker container) It's not a problem of docker.

Additional context 2022-04-18 15 42 23 raspberrypi 255f011ac2f1 2022-04-18 15 42 35 raspberrypi 815023484b59

afknst commented 2 years ago

Searched a bit and I think this may be a problem of crystal json parser. It works well after deleting all generated json files. Please, stop managing reading process by the creepy json files. You have a sql database to do that.

Solution, in the library, run find . -type f -name '*.json' -exec rm {} \;

Btw you'll lose all your reading process if you do this. I did it since I don't know which json file is damaged and I was too lazy to find out.

KandyWrong commented 2 years ago

For anyone who stumbles across this same problem and doesn't want to go through a bazillion JSON files to find the broken one, here's a quick work-around.

First, install jsonlint-php with: sudo apt install jsonlint-php

(substitute the package manager for whatever distro you're using)

Then run this command inside your manga directory: find . -name \*.json -print0 | xargs -0I {} jsonlint-php -q '{}'

I stole all this from https://superuser.com/a/699897

You might be able to repair the broken JSON. I just deleted it and mango regenerated it.