How to debug `error` event?

Hello!

I will give a quick summary first, with more information below if you need it:

  1. Googlebot seems to have issues loading my page.
  2. The issue seems to be aroundLatLng being set to null,null.
  3. This should not be possible in my code.
  4. Googlebot seems to be getting error: TypeError: Cannot convert a Symbol value to a string
  5. I don’t know how to further debug using search.on('error', ... as the information it provides seems very limited.

I appreciate the help. :slight_smile:




I noticed that my Error Logs on my Algolia Dashboard are being flooded:
image

The Response Header for that object:

{
  "requests": [
    {
      "indexName": "MY_INDEX",
      "params": "query= [ ... ] aroundLatLng=null%2Cnull [ ... ]"
    },
    {
      "indexName": "MY_INDEX",
      "params": "query= [ ... ] aroundLatLng=null%2Cnull [ ... ]

The Response Body:

{
  "message": "Invalid value for \"aroundLatLng\" parameter, expected float",
  "status": 400
}

Okay, simple! Make sure aroundLatLng is not "null,null".

…Except I have a block of code preventing it from ever being set to something like that, and all tests I can think of show the code working correctly.

Furthermore, in the Headers I see this:
From: googlebot(at)googlebot.com

So this seems to be happening only to googlebot. So using Google’s Search Console I did a live URL Inspection. According to the error logs from the inspection, I am getting this error:

Error
00:28.146
TypeError: Cannot convert a Symbol value to a string
https://www.website.com/my/algolia/code.js:1754

Line 1754 in this case is this block:

/* Error Handling */
search.on('error', function(error) {
  console.error(error);
});

Hi @kevin2,

Thanks for your detailed question!

Would it be possible to show your code where you are sending the query so that we can investigate further? If you are using InstantSearch you can create a minimal code sample at codesandbox.io using one of our templates here.

I look forward to your reply!

There is quite a bit of code, so I can’t send it all. This snippet includes the part that includes the setting of aroundLatLng, which I believe is the relevant part.

However, I can’t use the Google Search Console to debug this page to confirm that the error is still happening. Also, enabling aroundLatLngViaIP on the template app causes no results to be found.

Oh, oops! Sorry!

I forgot to include the link. :sweat_smile:

I understand that this is a difficult issue to debug, and maybe even impossible to check given the tools we have available and the fact that Algolia != Google.

What I was hoping for was perhaps some guidance on how to deal with the errors that Algolia is giving me, so that I can potentially track down where in my code the bug is occurring.

Right now all I have is that 1) My Algolia Dashboard Logs say that aroundLatLng is being set to null%2Cnull (a few well placed console.log messages imply that my code is never doing this) and 2) Algolia is catching the error Cannot convert a Symbol value to a string when googlebot runs my code.