N I C O
PPrisma
•Created by N I C O on 12/30/2024 in #help-and-questions
Getting error this.getGlobalTracingHelper(...).dispatchEngineSpans is not a function
@Nurul Thanks for answering, indeed it works in prisma v6.0.0, but I now have a new problem, my model has Ids as BigInt and I think that at the moment of sending the query, optimize can't process this Ids
personally I use this script to send bigints back to the client
Unhandled Rejection at: TypeError: Do not know how to serialize a BigInt
at JSON.stringify (<anonymous>)
at /home/nicotordev/Escritorio/spiritory/backend/node_modules/@prisma/extension-optimize/dist/index.js:1:1007
at Object.post (/home/nicotordev/Escritorio/spiritory/backend/node_modules/@prisma/extension-optimize/dist/index.js:1:1275)
at B (/home/nicotordev/Escritorio/spiritory/backend/node_modules/@prisma/extension-optimize/dist/index.js:1:2007)
at b.onFlush (/home/nicotordev/Escritorio/spiritory/backend/node_modules/@prisma/extension-optimize/dist/index.js:1:6501)
at b.forceFlush (/home/nicotordev/Escritorio/spiritory/backend/node_modules/@prisma/extension-optimize/dist/index.js:1:3567)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Unhandled Rejection at: TypeError: Do not know how to serialize a BigInt
at JSON.stringify (<anonymous>)
at /home/nicotordev/Escritorio/spiritory/backend/node_modules/@prisma/extension-optimize/dist/index.js:1:1007
at Object.post (/home/nicotordev/Escritorio/spiritory/backend/node_modules/@prisma/extension-optimize/dist/index.js:1:1275)
at B (/home/nicotordev/Escritorio/spiritory/backend/node_modules/@prisma/extension-optimize/dist/index.js:1:2007)
at b.onFlush (/home/nicotordev/Escritorio/spiritory/backend/node_modules/@prisma/extension-optimize/dist/index.js:1:6501)
at b.forceFlush (/home/nicotordev/Escritorio/spiritory/backend/node_modules/@prisma/extension-optimize/dist/index.js:1:3567)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
export default function convertBigIntToString(obj: any): any {
if (typeof obj === "bigint") {
return obj.toString();
} else if (obj instanceof Date) {
return obj.toISOString();
} else if (obj instanceof Map) {
return {
type: "Map",
value: Array.from(obj.entries()).map(([key, value]) => [
convertBigIntToString(key),
convertBigIntToString(value),
]),
};
} else if (obj instanceof Set) {
return {
type: "Set",
value: Array.from(obj).map(convertBigIntToString),
};
} else if (obj === null || typeof obj !== "object") {
return obj;
} else if (Array.isArray(obj)) {
return obj.map(convertBigIntToString);
} else {
return Object.fromEntries(
Object.entries(obj).map(([key, value]) => [
key,
convertBigIntToString(value),
]),
);
}
}
export default function convertBigIntToString(obj: any): any {
if (typeof obj === "bigint") {
return obj.toString();
} else if (obj instanceof Date) {
return obj.toISOString();
} else if (obj instanceof Map) {
return {
type: "Map",
value: Array.from(obj.entries()).map(([key, value]) => [
convertBigIntToString(key),
convertBigIntToString(value),
]),
};
} else if (obj instanceof Set) {
return {
type: "Set",
value: Array.from(obj).map(convertBigIntToString),
};
} else if (obj === null || typeof obj !== "object") {
return obj;
} else if (Array.isArray(obj)) {
return obj.map(convertBigIntToString);
} else {
return Object.fromEntries(
Object.entries(obj).map(([key, value]) => [
key,
convertBigIntToString(value),
]),
);
}
}
7 replies