deanStealth
PPrisma
•Created by deanStealth on 1/8/2025 in #help-and-questions
Prisma Promises not transferring context like Promises?
A typical pattern in software is
asyncLocalStorage.run(new Map(), () => {
const store = asyncLocalStorage.getStore();
//Generate our own txId for every request
const requestId = generateShortUUID();
store.set('txId', requestId);
//many other setttings like email if exist, clientId from http header if exist
//call controller next(); } Now, in the controller, and business logic and even libraries, this.log.info("some log") spits out all that same information. this information is captured through Promises. It seems prisma promises breaks that though so all my prisma logs that get logged are missing this info. I cannot tell which SQL queries are running against which requestId or email or client id. I filter in GCP the logs frequently on these things and the SQL logs all dissapear. is something missing from PrismaPromises to transfer the asyncLocalStorage context? how to get prisma logging "SQL log" so the underlying logger which calls asyncLocalStorage.getStore().get("txId") will work and get the txId for that request? (yes, this works with many clients as asyncLocalStorage is isolated to the context of each run).
In scala, the Promise has to propogate the context manually. In java, I have a reference to a CompletableFuture that does something similiar. Any reason this breaks in prisma?
//call controller next(); } Now, in the controller, and business logic and even libraries, this.log.info("some log") spits out all that same information. this information is captured through Promises. It seems prisma promises breaks that though so all my prisma logs that get logged are missing this info. I cannot tell which SQL queries are running against which requestId or email or client id. I filter in GCP the logs frequently on these things and the SQL logs all dissapear. is something missing from PrismaPromises to transfer the asyncLocalStorage context? how to get prisma logging "SQL log" so the underlying logger which calls asyncLocalStorage.getStore().get("txId") will work and get the txId for that request? (yes, this works with many clients as asyncLocalStorage is isolated to the context of each run).
In scala, the Promise has to propogate the context manually. In java, I have a reference to a CompletableFuture that does something similiar. Any reason this breaks in prisma?
13 replies