• Resolved Fibro Jedi

    (@fibrojedi)


    Heya,

    So I’m trying (again) to get RelevanSSI working and am failing again.

    When I try to build the index the following JavaScript error is generated.

    12:10:33.040 Truncating index. admin_scripts_free.js:19:11
    12:10:33.807 Uncaught SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
        <anonymous> URL/relevanssi/lib/admin_scripts_free.js:22
        jQuery 7
            c
            fireWith
            l
            o
            send
            ajax
            i
        <anonymous> URL/relevanssi/lib/admin_scripts_free.js:21
        jQuery 9
        <anonymous> URL/relevanssi/lib/admin_scripts_free.js:2
        jQuery 13
    admin_scripts_free.js:22:29

    I’ve replaced the path to the plugin folder with URL here, that’s not part of the error.

    I’ve done a cache clear server-side, hard clear etc. But the error returned. I’ve had to deactivate it while we figure it out as it makes the normal search return no results when the index is empty.

    Thanks!

Viewing 15 replies - 1 through 15 (of 25 total)
  • Plugin Author Mikko Saari

    (@msaari)

    That sounds like there’s a server error and the server is returning the error instead of the expected result.

    Try this: with Chrome, open up Inspector and the Network tab there, go to the indexing page and start the indexing. This should fire a request to admin-ajax.php with the action relevanssi_count_posts. What is on the “Response” tab for the request? There should be a string with the number of posts, but in your case, there’s not.

    Thread Starter Fibro Jedi

    (@fibrojedi)

    The response is…

    true for action relevanssi_truncate_index

    it never seems to get past “wiping the index”. I’ve tried the various fixes you already suggest in your documentation for that issue before I opened the ticket.

    The only other action triggering is heartbeat which gives a response of

    JSON:
    `wp-auth-check true
    server_time 1648154968′

    Your action of relevanssi_count_posts was not reached even after 4 minutes.

    Does this help? Haha.

    Thanks in advance!

    Thread Starter Fibro Jedi

    (@fibrojedi)

    Okay I did a refresh and got it to “counting Posts” the response now is

    "506"
    for
    relevanssi_count_missing_posts

    Plugin Author Mikko Saari

    (@msaari)

    Ok, that looks like the correct response. What happens then? What is the error message now?

    Thread Starter Fibro Jedi

    (@fibrojedi)

    When I click “Index Unindexed Posts” (given the indexation database is empty) I get

    12:13:50.876 Uncaught SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
        <anonymous> https://path-to-plugins-folder/relevanssi/lib/admin_scripts.js:195
        jQuery 7
        <anonymous> https://path-to-plugins-folder/relevanssi/lib/admin_scripts.js:194
        jQuery 9
        <anonymous> https://path-to-plugins-folder/relevanssi/lib/admin_scripts.js:178
        jQuery 13
    admin_scripts.js:195:26

    If I expand each of the jQuery -number- entries, the console yields

    12:13:50.876 Uncaught SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
        <anonymous> https://path-to-plugins-folder/relevanssi/lib/admin_scripts.js:195
        jQuery 7
            c
            fireWith
            l
            o
            send
            ajax
            i
        <anonymous> https://path-to-plugins-folder/relevanssi/lib/admin_scripts.js:194
        jQuery 9
            dispatch
            handle
            add
            Ee
            each
            each
            Ee
            on
            n
        <anonymous> https://path-to-plugins-folder/relevanssi/lib/admin_scripts.js:178
        jQuery 13
            e
            t
            setTimeout handler*Deferred/then/l/<
            c
            fireWith
            fire
            c
            fireWith
            ready
            B
            EventListener.handleEvent*
            <anonymous>
            <anonymous>
    admin_scripts.js:195:26

    The admin-ajax is still giving “506” as the response.

    While you mull that over, I’ll check some other settings. I’m not combining scripts any more so it’s not down to that, but I’ll see if I can find other conflicts. I’m a coder, but I am not great with JSON errors!

    • This reply was modified 2 years, 8 months ago by Fibro Jedi. Reason: hiding my path to plugins URL
    Plugin Author Mikko Saari

    (@msaari)

    Unfortunately, that tells nothing new to me. The problem still seems to be the same: for some reason, the server response is not proper JSON, which to me suggest there’s some kind of server error.

    What does the indexing status box show, what’s the last thing there when the indexing gets stuck? There’s “Truncating index”, then “Counting posts”, does it show the “506 posts found” message?

    Looking at the server PHP error log may also be helpful.

    Thread Starter Fibro Jedi

    (@fibrojedi)

    Sorry for the delay – just so you know I’m not ignoring you, I will get a reply on this tomorrow for you.

    I now have COVID symptoms and my wife tested positive again, so we’re not doing well. But I have this tab pinned on my browser so I’ll try to remember to do it tomorrow.

    [b]Edit[/b] as I have some admin URL rewriting, what URL is your plugin trying to reach that might be failing? I may just need to do some extra rewriting myself, in case that’s the cause – or part of it.

    • This reply was modified 2 years, 8 months ago by Fibro Jedi. Reason: Adding an extra thought re: URL rewriting
    Plugin Author Mikko Saari

    (@msaari)

    Relevanssi uses the default ajaxurl from WP, so whatever that is, usually wp-admin/admin-ajax.php.

    Take your time, I have a subscription for all these threads so I’ll be pinged whenever something happens. Editing a post doesn’t ping me, so if you add something important like this here, please add a new post instead of editing an old post.

    Thread Starter Fibro Jedi

    (@fibrojedi)

    Okay, so Relevanssi is accessing admin-ajax.php fine so it’s not my rewrite rules.

    I cleared the error log and reran indexing. All that appeared was

    [28-Mar-2022 11:07:50 UTC] PHP Warning: urlencode() expects parameter 1 to be string, array given in /home/fibrojedi/public_html/wp-includes/formatting.php on line 5501

    but given how busy my site is this could have been triggered by anything. Having done some research about the error – when it crops up on other plugins it is sometimes (though not always) a plugin conflict.

    I’ve managed to get a localhost version working so I’ll see if that yields the answers.

    • This reply was modified 2 years, 8 months ago by Fibro Jedi.
    Plugin Author Mikko Saari

    (@msaari)

    That doesn’t sound like a probable cause, but it’s possible. Since jQuery is reporting those errors, I’d expect the error to also show up in the Network debugging; if you go through all the responses from admin-ajax.php, I’d expect the error to show up there as well.

    Thread Starter Fibro Jedi

    (@fibrojedi)

    Okay, the plot thickens.

    I set up a localhost, with the same settings and plugins, including the plugins with the same settings for those plugins and it worked absolutely fine.

    I reinstalled Relevanssi in case that was the issue and it’s not.

    On localhost the console does this (before returning the posts indexed)

    13:59:06.199 Truncating index. admin_scripts_free.js:19:11
    13:59:06.985 Truncate index: true admin_scripts_free.js:23:12
    13:59:06.986 Counting posts. admin_scripts_free.js:31:12
    13:59:07.709 Counted 415 posts.

    On the live site I get (when running “Build the Index”

    14:30:50.023 attachment_url_value is undefined script.js:32:11
    14:30:50.028 Drop-down not found options-general.php:2486:14
    14:30:55.300 Truncating index. admin_scripts_free.js:19:11
    14:30:56.029
    Uncaught SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

    The last admin-ajax request screen_id "settings_page_relevanssi/relevanssi" has a **true** response. (Now, not getting the number).

    If I run “Index Unindexed posts”, I do get “491” for the response.

    Is there some way for me to see the AJAX request to see what my server’s “unexpected character” is? It must be something server-side if I can get it working on localhost.

    Plugin Author Mikko Saari

    (@msaari)

    You can see the requests and the response values from the browser console Network tab, which you’ve been looking at. That’s the response where the unexpected character is.

    The relevanssi_truncate_index action should get a response of true, so that seems correct to me.

    The unexpected character error might be some character encoding issue as well, something mystic like invisible characters, like an invisible extra space character in your theme functions.php or something very tricky like that.

    Thread Starter Fibro Jedi

    (@fibrojedi)

    But "relevanssi_count_missing_posts" returns 491 (which seems correct) but then there’s nothing until the heartbeat/has_focus check.

    I will see if I can find random characters then, as I’m running out of options and I really do want this to work!

    Thanks for your time ??

    Plugin Author Mikko Saari

    (@msaari)

    I thought one possible cause might be having files in UTF-8 with BOM, but I tried saving my theme functions.php with a BOM and that didn’t break the indexing. I then tried adding a line feed, a space and a non-breaking space at the beginning of the functions.php file and while those extra characters did show up in the JSON response from admin-ajax.php, they did not stop the indexing from working. It was also clearly visible that there was something extra in the JSON response.

    Thread Starter Fibro Jedi

    (@fibrojedi)

    Hmm, I just wish console errors would say **which** unexpected character it found as it would make this kind of job so much easier!

Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘Uncaught SyntaxError: JSON.parse: unexpected character at line 1 column 1’ is closed to new replies.