I built a webapp on Vercel using the t3-stack (next.js, trpc, prisma and nextauth).
Everything was warking well in production until i got a 500 error on a trpc call.
The log showed by vercel is :
(node:8) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 response listeners added to [ClientRequest]. Use emitter.setMaxListeners() to increase limit
And from that moment every requests shows the same message. Redeploying the project solved (temporary?) the problem, but i cannot find the source of the error.
The request that triggered the error is :
updateAboutProfile: publicProcedure
.input(
z.object({
city: z.string().nullish(),
cognome: z.string().nullish(),
id: z.string(),
nome: z.string().nullish(),
pec: z.string().nullish(),
phone: z.string().nullish(),
provincia: z.string().nullish(),
region: z.string().nullish(),
})
)
.mutation(async ({ ctx, input }) => {
//update profile in prisma
const updatedProfile = await ctx.prisma.profile.update({
where: { userId: input?.id },
data: {
city: input.city || "",
cognome: input.cognome || "",
nome: input.nome || "",
pec: input.pec || "",
phone: input.phone || "",
provincia: input.provincia || "",
region: input.region || "",
},
});
//update profile on the elasticsearch index
return ctx.elastic.update({
index: "user_profiles",
id: updatedProfile.id,
doc: {
slug: updatedProfile.id,
nome: updatedProfile.nome,
cognome: updatedProfile.cognome,
provincia: updatedProfile.provincia,
region: updatedProfile.region,
shortDescription: updatedProfile.shortDescription,
image: updatedProfile.image,
keywords: updatedProfile.keyword,
},
});
}),