Transaction Problem With Related Model

Hello,

I have a problem with transaction. For example I have code like this;

await Database.transaction(async (trx) => {
  const work = await Work
    .query()
    .transacting(trx)
    .where('id', params.workId)
    .firstOrFail()

// some other codes
})

Is it simple right? It works great. But If I add a line to fetch related data, I get an error on tests;

await Database.transaction(async (trx) => {
  const work = await Work
    .query()
    .transacting(trx)
    .with('option')
    .where('id', params.workId)
    .firstOrFail()

// some other codes
})

This is the error which I get;

1. a new work suggestion should be able to create
  Error: Test timeout, ensure "done()" is called; if returning a Promise, ensure it resolves.
    at Test._parseError (/home/ozzy/Desktop/gitlab/api/node_modules/japa/src/Test.js:109:16)
    at Callable.args.run.then.then.catch (/home/ozzy/Desktop/gitlab/api/node_modules/japa/src/Test.js:195:21)

I believe that this is an issue something similar with How to do query inside transaction after initialized . But I already added .transacting method to method chain.

What is the problem?

1 Like

I guess this is a bug.