Hey! When upgrading Next from 12.1.6 to 12.2.3 (fo...
# ask-questions
n
Hey! When upgrading Next from 12.1.6 to 12.2.3 (for the stable Middleware release), I get the following error from the
trackingCallback
function, which runs inside the root Middleware function (
middleware.ts
):
Copy code
error - unhandledRejection: TypeError: fetch failed
    at Object.processResponse (evalmachine.<anonymous>:3033:34)
    at evalmachine.<anonymous>:3366:42
    at node:internal/process/task_queues:141:7
    at AsyncResource.runInAsyncScope (node:async_hooks:201:9)
    at AsyncResource.runMicrotask (node:internal/process/task_queues:138:8) {
  cause: TypeError: define_process_default.nextTick is not a function
      at Client.[dispatch] (evalmachine.<anonymous>:5298:34)
      at Client.dispatch (evalmachine.<anonymous>:3987:33)
      at Pool.[dispatch] (evalmachine.<anonymous>:4212:32)
      at Pool.dispatch (evalmachine.<anonymous>:3987:33)
      at Agent2.[dispatch] (evalmachine.<anonymous>:6611:27)
      at Agent2.dispatch (evalmachine.<anonymous>:3987:33)
      at evalmachine.<anonymous>:3752:83
      at new Promise (<anonymous>)
      at dispatch (evalmachine.<anonymous>:3752:16)
      at httpNetworkFetch (evalmachine.<anonymous>:3657:65)
}
Here’s how my tracking callback function looks:
Copy code
trackingCallback: async (experiment, result) => {
  // Track experiment result with Rudderstack
  await fetch(`${rudderstack.dataPlaneUrl}/v1/track`, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      Authorization: `Basic ${rudderstack.basicAuthHeader}`,
    },
    body: JSON.stringify({
      anonymousId: anonymousId,
      event: "experiment",
      properties: {
        experimentId: experiment.key,
        variationId: result.variationId,
      },
    }),
  })
},
I’m using the latest version of
@growthbook/growthbook
, tested that the tracking URL of Rudderstack is valid, and have verified that the error does not happen with Next 12.1.6. Has anyone else experienced this error – and maybe found a solution?
f
n
Thanks! I managed to solve it by downgrading to Next 12.2.2