Fetch failed: JSON.parse

Hi,

I’m getting this error when loading the Admin Panel on my live hosted test space.

Fetch Failed:
JSON.parse: unexpected character at line 1 column 1 of the JSON data

On MAMP it is working without this error. I’ve loaded up the complete system, without changing anything so far. I’m using PHP 5.6.12 there.

Does anybody know what is going wrong there?

Thanks!

Hard to tell exactly without knowing which piece of JSON-data it refers to, but I would expect that there is an unsupported character at the start of this piece of JSON. Like a non-unicode character which the system does not handle very well.

Thanks for your reply Gingah! I wish I would know, to which file the error message refers. There is just a red box with the error message I posted above, with an empty white box inside. No hint to the file where the error occurs. Strange, that it seems to work on localhost.

It’s probably the GPM json file that dictates which plugin/theme updates are available. Not sure why it would be an issue for you and no one else.

Can you double check that your remote server has all the PHP requirements?

Thank you for the hint! This is no solution, of course, but the error no longer occurs when I set:

/user/plugins/admin/admin.yaml

19  enable_auto_updates_check: false

I’m not 100% sure, but everything seems fine so far, regarding the requirements on my remote server. I’ll dive deeper into this, as soon as I have a bit more time.

Thanks for your time and many many thanks for the brilliant CMS! :slight_smile:

I had exactly the same error. In my case it was due to a bug in a plugin. This bug led to some text output during initialization of the plugin. This output was written to the html source code before the tag. It did not appear on the final webpage and it did not led to any misbehavior of the webpage. The only unusual behavior I could observe was the “fetch failure” error message, which appeared in the admin panel only. So maybe you should check in your browser, if your html source code starts with anything else but when the error message appears.

Thanks karochris! Good point, but unfortunately there is no code before the tag :expressionless:

And my plugin situation is pretty basic at this moment:

Admin Panel v1.1.2
Email v2.4.1
Error v1.5.1
Form v1.3.0
Login v2.0.0
Markdown Notices v1.0.0
Problems v1.4.3

I just experienced the same issue once I updated to Grav 1.1.2 and related plugin updates for my long-running Grav site hibbittsdesign.org. Just on my live server, the same site running on MAMP seems fine.

The setting of check for updates to false also masks the issue for me in the short-term. Any further ideas?

I think it’s been established that there’s a plugin outputting data early. I’m not sure which plugin it is however. Did you check your HTML source and see if there was anything output before the HTML doctype as @karochris describes.

@paulhibbits, if you can PM me a zip of your site where it happens, I can try to replicate it locally and debug by turning off plugins until the error goes away.

I’ve been able to have this issue fixed with my super-awesome hosting company (https://reclaimhosting.com/) after they looked into the underlying causes of the server 500 errors being generated when GPM getUpdates() was called.

Here is the exact reply I got back from their support person, in case it might contain clues that may be helpful to others:

“It looks like this was being caused by CloudLinux, the resource allocation kernel we use (same software that allows the alternative PHP versions and a few other things in our shared hosting environment). The Apache log was reporting that it couldn’t allocate any memory to the process. I just adjusted some settings across all accounts for memory limits and I’m not seeing the error anymore. Let me know if it’s still happening in any of your installs, but seems like it wasn’t necessary related to the upgrade but server related.”

I’m getting this error, too (screenshot below), on two different sites. Both on the same server, being served over SSL by Nginx as a reverse proxy.

Fetch-failed-JSON

The following from the browser devtools:

POST https://www.iainsgillis.com/admin/notifications.json/task:getNotifications 500 ()

    o                       @ admin.min.js?92aed16245:4
    value                   @ admin.min.js?92aed16245:4
    (anonymous function)    @ admin.min.js?92aed16245:4
    t                       @ vendor.min.js?92aed16245:1
    (anonymous function)    @ admin.min.js?92aed16245:4
    t                       @ vendor.min.js?92aed16245:1
    (anonymous function)    @ admin.min.js?92aed16245:1
    (anonymous function)    @ admin.min.js?92aed16245:1
    t                       @ vendor.min.js?92aed16245:1
    window.webpackJsonpGrav @ vendor.min.js?92aed16245:1
    (anonymous function)    @ admin.min.js?92aed16245:1

Unexpected token < in JSON at position 0 at SyntaxError: Unexpected token < in JSON at position 0 

    s                       @ admin.min.js?92aed16245:4

POST https://www.iainsgillis.com/admin/ajax.json/task:getnewsfeed 500 ()

    o                       @ admin.min.js?92aed16245:4
    value                   @ admin.min.js?92aed16245:4
    value                   @ admin.min.js?92aed16245:4
    (anonymous function)    @ admin.min.js?92aed16245:4
    j                       @ jquery-2.1.4.min.js?92aed16245:2
    fireWith                @ jquery-2.1.4.min.js?92aed16245:2
    ready                   @ jquery-2.1.4.min.js?92aed16245:2
    I                       @ jquery-2.1.4.min.js?92aed16245:2

Unexpected token < in JSON at position 0 at SyntaxError: Unexpected token < in JSON at position 0

    s                       @ admin.min.js?92aed16245:4

These errors occur on any save/refresh/navigation within the admin panel.

There’s an additional instance of the same error when clearing the cache from within the admin panel:

GET https://www.iainsgillis.com/admin/cache.json/task:clearCache/admin-nonce:89a9b7f7b63b53d3ba786748d5c5fe25 500 ()   

    o                       @ admin.min.js?71de152ee2:4
    value                   @ admin.min.js?71de152ee2:4
    (anonymous function)    @ admin.min.js?71de152ee2:4
    dispatch                @ jquery-2.1.4.min.js?71de152ee2:3
    r.handle                @ jquery-2.1.4.min.js?71de152ee2:3

I’ve checked the source of the render pages: nothing is being output before the initial <!DOCTYPE html>. Also: PHP memory limit is set to 128M.

Somehow related, perhaps: trying to update a plugin from the admin panel also hangs, with the server returning a 404 error for /admin/plugins.json/task:getPackagesDependencies. Similarly, the server returns a 500 error for /admin/backup.json/task:backup/admin-nonce:89a9b7f7b63b53d3ba786748d5 c5fe25.

Could all of these be related to the proxy setup? No problems whatsoever when doing any of the updates, backups, or cache-clearing from the CLI.

Hope this is helpful.

@iansgillis you really need to look at the server error logs to see what it says is causing that 500 error.

@rhukster Forest for the trees on my part. Thanks for setting me straight! First glance: rewrite or internal redirection cycle on – must have messed up something in the proxy configuration. I’ll dig into that properly tomorrow.

Sorry for the long-coming reply here: bathroom renos and starting a new job necessitated other priorities.

Got this sorted: bad (but obviously nonfatal) regex in my nginx config to blame. Right as rain now.

Glad you got it sorted!