narrow-psychiatrist-15437
07/27/2022, 1:22 PMtrackingCallback
function, which runs inside the root Middleware function (middleware.ts
):
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:
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?future-teacher-7046
narrow-psychiatrist-15437
07/28/2022, 11:20 AM