cube-js / cube

📊 Cube — Universal semantic layer platform for AI, BI, spreadsheets, and embedded analytics
https://cube.dev
Other
18.02k stars 1.78k forks source link

Unexcepted behaviour on SAFARI with @cube.js/core and unreadable error message #6149

Open hilaliMoncef opened 1 year ago

hilaliMoncef commented 1 year ago

Hello everybody. We are a team of devs working with cube for several months now and we are really really happy with it. It's always delivering and easy to use. But recently, we stumbled upon a bug only on SAFARI browser.

Describe the bug On Chrome or Firefox, everything is fine. But on safari, we use the Cube.js method "load" to retrieve the simplest data possible from Cube. But we receive the following error on the console :

undefined is not an object (evaluating 'response.results.length')

We tried few things to debug this issue. First of all, the errors occurs in the following function :

loadResponseInternal(response) {
    if (
      response.results.length &&
      response.results[0].query.responseFormat &&
      response.results[0].query.responseFormat === ResultType.COMPACT
    ) {
      response.results.forEach((result, j) => {
        const data = [];
        result.data.dataset.forEach((r) => {
          const row = {};
          result.data.members.forEach((m, i) => {
            row[m] = r[i];
          });
          data.push(row);
        });
        response.results[j].data = data;
      });
    }
    return new ResultSet(response, {
      parseDateMeasures: this.parseDateMeasures
    });
  }

Here, the response object (received from network) does not contain a "results" object. So I tried to understand what does this object contain instead ? Using the safari debugger, I noticed that the "response" object I receive is structured like this :

{ error: "[object Blob]" }

It's impossible to read the error object to try to understand what's going on. From there I asked myself : maybe there is an error in my request or in my cube cloud environment. On chrome and firefox, the exact same request produces no error. Also, when I open the network tab of Safari's developer tools, I can see the GET request and more importantly I can see that I correctly receives data from cube on that request. So the error is probably on the response parsing somewhere.

I also tried to look at Cube Cloud logs, but there is nothing there.

Expected behavior The JS SDK should parse correctly the response object (if it's a success or an error) in Safari and extract either a ResultSet or an error object.

const result = await cubejs.load({
    measures: ["Campaigns.spend"],
    order: {
      "Campaigns.date": "asc",
    },
  });
  console.log(result);

Version: "@cubejs-client/core" : "^0.31.46"

hilaliMoncef commented 1 year ago

Hello @vasilev-alex ! Did you had any time to look at this issue ? Still having the issue on Safari.