Service Unavailable error with the fetchEntries function

Hi,

We’re getting “Service Unavailable” when trying to pull content. We were on a free account for development but have since upped the account thinking that the API limits were the issue. After upgrading we still can’t pull from the CMS using fetchEntries function.

Weirdly, we can use the rest API by fetching directly. Since we’re hoping to launch today and changing everything to using the API would take a lot of effort and push the launch date, we’re hoping to fix the fetchEntries issue.

Please fill out as many of the following questions as possible so we can help you promptly! If you don’t know how to answer or it does not apply, feel free to remove it or leave it blank.

Builder content link

Builder public api key
9da1c69eaad44798835fb0df36bc255a

What are you trying to accomplish
Use the fetchEntries function @builder.io/sdk-react

Screenshots or video link

Code stack you are integrating Builder with
Hydrogen (Remix), Oxygen.

*Reproducible code example

Code has been working for several weeks, no adjustments have been made. Error is “Service Unavailable” see screenshot.

await fetchEntries({
            ...builderConfig,
            model: 'room-images',
            options: {
              enrich: true
            },
            query: {
              'data.inspirations.inspiration.id': inspiration,
            },
})

This (below) fetch works for the same content type using the same key and same query.

          let res = await fetch(`https://cdn.builder.io/api/v3/content/${model}?apiKey=${env?.PUBLIC_BUILDER_KEY}&limit=100&offset=${offset}${query}&includeRefs=true&noTraverse=false`, {
              headers: {
                  'content-type': 'application/json',
              },
              method: 'GET'
          }).then(r => r.json());

Hello @innes,

Could you please confirm the version of the builder you are using, @builder.io/sdk-react?

@builder.io/sdk-react”: “^1.0.28”

The latest version available is 2.0.13 of sdk-react, would it be possible for you to test the latest version ?

We’re having issues with the isolated-vm dependency node-gyp specifically, this seems to be a current issue, it has a few threads in Github. Installing it for us a no go to get working today.

Is our account throttled? “Service Unavailable” doesn’t seem like it’s on our side.

Hello @innes,

To resolve isolate-vm error you may find help at the following link Integration Tips - Builder.io

In your Remix route’s loader that is responsible for fetching the page content from Builder.io (or any other code path that only executes on the server), import “@builder.io/sdk-react/node/init” and call initializeNodeRuntime():

// ($slug)._index.tsx
import { fetchOneEntry } from '@builder.io/sdk-react';

export const loader = async ({ params, request }: LoaderFunctionArgs) => {
  // NOTE: the import must be inside the loader itself.
  const { initializeNodeRuntime } = await import(
    '@builder.io/sdk-react/node/init'
  );

  await initializeNodeRuntime();

  const page = await fetchOneEntry({ /** */ });

  return { page };
};

We’re using Oxygen there is no Node runtime. It’s Cloudfron, a worker-based environment.

We do have a lot of calls to fetchEntries, they’re sequential and run one after another, does the fetchEntries function possibly hitting an API rate limit? The fetchEntries call is the last on the page.

Hello @innes,

We don’t have any rate limits; therefore, I doubt that will be an issue. Additionally, we have not heard of any such problems from any other customer using fetchEntries. Could this be an issue with the query?

            query: {
              'data.inspirations.inspiration.id': inspiration,
            },

Have you tried running fetchEntries without using the query ?

Same query works with the REST API, also, same query with fetchEntries was functioning. It’s a new error “Service Unavailable”.

https://cdn.builder.io/api/v3/content/room-images?apiKey=9da1c69eaad44798835fb0df36bc255a&limit=30&noTraverse=true&includeRefs=true&omit=meta.componentsUsed&enrich=true&query.data.inspirations.inspiration.id="9bef3e38c0e44ed990adb80b41a6ff33"

Seems to be the enrich true option. Something is breaking there, it’s a small content type and we’re only pulling 30 entries.

Without the enrich true option works:
https://cdn.builder.io/api/v3/content/room-images?apiKey=9da1c69eaad44798835fb0df36bc255a&limit=30&noTraverse=true&omit=meta.componentsUsed&query.data.inspirations.inspiration.id="9bef3e38c0e44ed990adb80b41a6ff33"

We’re not sending the enrich option over with the REST API so that might be why it’s not working.

Hello @innes,

We have identified an issue with using reference queries that is causing a memory spike. Despite no recent changes, we suspect that the issue may be due to the data size, which has grown to over 3483 + reference queries. We are currently investigating this matter internally and will keep you updated on our progress.

Thank you.

Hello @innes,

Could you please confirm if you have recently added a circular reference? It seems that our findings indicate that the issue may be due to a circular reference.

The “Room Images” model contains a collections field, which is a list of references to the “Collections” model. The “Collections” model, in turn, contains a reference to the “Room Image” model, creating a circular reference.