Timeout on Builder.flushGetContentQueue

Hello,

We are using next.js for our builder website. However recently by running next.js command to create production optimized build “next builds/npm run build” we started getting the following errors:

/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2283
            throw new Error("Fetching content failed, expected apiKey to be defined instead got: ".concat(this.apiKey));
            ^

Error: Fetching content failed, expected apiKey to be defined instead got: null
    at Builder.flushGetContentQueue (/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2283:19)
    at Timeout._onTimeout (/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2224:27)
    at listOnTimeout (node:internal/timers:581:17)
    at process.processTimers (node:internal/timers:519:7)

Node.js v20.16.0
/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2283
            throw new Error("Fetching content failed, expected apiKey to be defined instead got: ".concat(this.apiKey));
            ^

Error: Fetching content failed, expected apiKey to be defined instead got: null
    at Builder.flushGetContentQueue (/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2283:19)
    at Timeout._onTimeout (/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2224:27)
    at listOnTimeout (node:internal/timers:581:17)
    at process.processTimers (node:internal/timers:519:7)

Node.js v20.16.0
 ⨯ Static worker exited with code: 1 and signal: null
 ⨯ Static worker exited with code: 1 and signal: null
/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2283
            throw new Error("Fetching content failed, expected apiKey to be defined instead got: ".concat(this.apiKey));
            ^

Error: Fetching content failed, expected apiKey to be defined instead got: null
    at Builder.flushGetContentQueue (/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2283:19)
    at Timeout._onTimeout (/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2224:27)
    at listOnTimeout (node:internal/timers:581:17)
    at process.processTimers (node:internal/timers:519:7)

Node.js v20.16.0
/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2283
            throw new Error("Fetching content failed, expected apiKey to be defined instead got: ".concat(this.apiKey));
            ^

Error: Fetching content failed, expected apiKey to be defined instead got: null
    at Builder.flushGetContentQueue (/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2283:19)
    at Timeout._onTimeout (/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2224:27)
    at listOnTimeout (node:internal/timers:581:17)
    at process.processTimers (node:internal/timers:519:7)

Node.js v20.16.0
/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2283
            throw new Error("Fetching content failed, expected apiKey to be defined instead got: ".concat(this.apiKey));
            ^

Error: Fetching content failed, expected apiKey to be defined instead got: null
    at Builder.flushGetContentQueue (/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2283:19)
    at Timeout._onTimeout (/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2224:27)
    at listOnTimeout (node:internal/timers:581:17)
    at process.processTimers (node:internal/timers:519:7)

Node.js v20.16.0
/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2283
            throw new Error("Fetching content failed, expected apiKey to be defined instead got: ".concat(this.apiKey));
            ^

Error: Fetching content failed, expected apiKey to be defined instead got: null
    at Builder.flushGetContentQueue (/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2283:19)
    at Timeout._onTimeout (/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2224:27)
    at listOnTimeout (node:internal/timers:581:17)
    at process.processTimers (node:internal/timers:519:7)

Node.js v20.16.0
/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2283
            throw new Error("Fetching content failed, expected apiKey to be defined instead got: ".concat(this.apiKey));
            ^

Error: Fetching content failed, expected apiKey to be defined instead got: null
    at Builder.flushGetContentQueue (/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2283:19)
    at Timeout._onTimeout (/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2224:27)
    at listOnTimeout (node:internal/timers:581:17)
    at process.processTimers (node:internal/timers:519:7)

Node.js v20.16.0
/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2283
            throw new Error("Fetching content failed, expected apiKey to be defined instead got: ".concat(this.apiKey));
            ^

Error: Fetching content failed, expected apiKey to be defined instead got: null
    at Builder.flushGetContentQueue (/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2283:19)
    at Timeout._onTimeout (/opt/avengers/node_modules/@builder.io/sdk/dist/index.cjs.js:2224:27)
    at listOnTimeout (node:internal/timers:581:17)
    at process.processTimers (node:internal/timers:519:7)

Node.js v20.16.0

> Build error occurred
Error: Jest worker encountered 4 child process exceptions, exceeding retry limit
    at ChildProcessWorker.initialize (/opt/avengers/node_modules/next/dist/compiled/jest-worker/index.js:1:11580)
    at ChildProcessWorker._onExit (/opt/avengers/node_modules/next/dist/compiled/jest-worker/index.js:1:12545)
    at ChildProcess.emit (node:events:519:28)
    at ChildProcess._handle.onexit (node:internal/child_process:294:12) {
  type: 'WorkerError'
}

Yes, the key is passed correctly as Environment variable and everywhere get it like:

builder.init(process.env.NEXT_PUBLIC_BUILDER_API_KEY!);
Builder.isStatic = true;

And this is running within a docker build we also pass the key as ARG. We have also tried to debug and run it manually ensuring the key exists both within .env file and as actuall linux env variable.

We just started receiving this error and previously it was not showing. Is it possible something changed on the builder’s side ?

Kind Regards,
Ivan

Some additional info:

  • this seems although build in docker at random to be present on some environments and on other not
  • managed to trace it to the new versions of the sdk package as on version 2.2.6 everything works
  • further more even if manage to build on the new sdk version the next.js revalidation fails with also the same error where public key is “null” although it’s present and define correctly

Hello @ivan.iliev,

Could you confirm which builder SDK you are using? Is it @builder.io/react or @builder.io/sdk-react? Additionally, could you confirm if you are using builder dev-tools?

Hey @manish-sharma ,

We used:

  "dependencies": {
    "@builder.io/dev-tools": "^0.2.13",
    "@builder.io/react": "^3.2.4",
    "@builder.io/sdk": "^2.2.2", (Actual installed version was 2.2.9)
    "next": "14.1.0",
    "react": "18.2.0",
    "react-dom": "18.2.0"
  },

After changing it to:

  "dependencies": {
    "@builder.io/dev-tools": "^0.2.13",
    "@builder.io/react": "^3.2.4",
    "@builder.io/sdk": "2.2.6", (pinned version)
    "next": "14.1.0",
    "react": "18.2.0",
    "react-dom": "18.2.0"
  },

Problem disappeared.

A bit more inform for the error we use Azure DevOps for building pipeline of a docker container which simply does:

  • copy the code
  • npm install
  • npm run lint
  • npm run build
  • npm run start

The strange thing is that it was “npm run build” failing when building locally, but not in Azure DevOps. However, when we deploy a successful build from Azure then we were seeing the same error on the next.js revalidation during runtime.

Same issue after switching the version simply disappeared even if I tried to reproduce everything seems that the older version was working while the new is not.

Hello @ivan.iliev,

We have the latest version of “@builder.io/react” which is 4.0.4. We recommend upgrading to this version along with the latest SDK @builder.io/sdk version to see if that helps resolve this error.