1

I am a bit lost. I have a really time-intensive mysql insert to perform via prisma. Right now, I am using the t3 stack (nextjs + prisma + mysql on planetscale). Now this very long task always times out, everytime I try to execute it:

await prisma.megaItem.create( Error occurred during query execution: ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Server(ServerError { code: 1105, message: "vttablet: rpc error: code = Aborted desc = transaction 1671642640521425196: in use: in use: for tx killer rollback (CallerID: ny8ion72xu651v6m0unq)", state: "HY000" })) })

I tried to move it out of my serverless functions and put it on its own nodejs server. But the same happens in there? I am not sure how I can keep this very long task running.

In my serverless function, I call my nodejs server:

await axios.post('http://localhost:3333', {
        items
      })

In nodejs with express, I want to run the actual task:

app.post('/', async (req, res) => {
    //first, i loop through the items and put them into the right format, to do a prisma insert
    let prismaItems = await Promise.all(items.map(async (item, i) => {

        let bla = await Promise.all(innerItem.bla.map(async innerItem => {
    //...


    //then, at some point, after I have this mega-query together, i want to put it all into prisma:
        await prisma.megaItem.create({
        data: {
            title: "My title",
            sentences: {
                create: [
                    ...prismaItems
                ]
            }

        },
    });

All of this works when I put in not-so-much data, but if I put a lot, it will break.

Is there a way for my to NOT await the response of the server via async/await or to have the server do its thing for multiple minutes, without the frontend waiting for a response? The problem seems to be that after a seconds of running, the connection is lost or broken up and the task cannot complete.

antonwilhelm
  • 5,768
  • 4
  • 19
  • 45
  • I also have this issue. I am not sure what is wrong with this question that no one has responded? – schmell Jun 26 '23 at 15:47

0 Answers0