Closed EdAndrade closed 9 months ago
Can you show your tested code ? I guess you are probably using a transaction in it
Transactions cannot be nested, so if this is your case, you need to use another strategy for these specific tests
Yes @Julien-R44 for sure, i have just censured some parts because its a enterprise code, but you can ask if you need something else.
Please search for transactions in your tested code. I'm pretty sure this is the problem If not, can you create a replication repo?
I searched again, only have these global transactions that are runned in setup and teardown. I will create a replication repo
Hey.
I have the same issue.
I migrated all my code trying multiple methods (same as the ones mentioned in the issue) and couldn't find a workaround.
I don't have any other transactions declared in explicitely in my app, but maybe the v6 upgrade made some happen in the background?
Hey, same as above : ideally, it would be super handy to share a reproduction repo if possible please
@Julien-R44 I'm on it right now, but it occurs in company code and I fail to create a reproduction in a repository.
I'm digging on the Lucid code to learn more about transactions because I'm 100% sure I don't create one manually in my code.
https://github.com/Tahul/lucid-transactions-repro
I'm working on the repro in this repository.
Thanks a lot, let me know if you are able to reproduce
@Julien-R44 ;
I got it.
It seem to be related to SQL queries made through anything behind HTTP.
This test is causing it 100% of the time:
Note this behavior was supported in Adonis 5 (transactions made for data altered through HTTP queries).
Instructions to run:
Setup local MySQL database (I use sandbox
as name)
This is my .env
TZ=UTC
PORT=3333
HOST=localhost
LOG_LEVEL=info
APP_KEY=zKXHe-Ahdb7aPK1ylAJlRgTefktEaACi
NODE_ENV=development
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=root
DB_PASSWORD=
DB_DATABASE=sandbox
pnpm i && node ace migration:run && node ace test
should get you expected result.
okay so this is the output i have :
we can see that the test timeout. if you disable timeouts then you shouldn't get this error anymore :
test(`create ${batchSizes} TestData`, async ({ assert }) => {
for (let i = 0; i < batchSizes; i++) {
await fetch(`http://${env.get('HOST')}:${env.get('PORT')}/test`, {
method: 'POST',
body: JSON.stringify({
text: faker.word.sample(),
text2: faker.word.sample(),
text3: faker.word.sample(),
text4: faker.word.sample(),
}),
})
}
assert.equal(true, true)
}).disableTimeout() // 👈👈👈
Let me know if it works for you
That's also what I just noticed in my own test suite by raising the timeout by a lot.
Thank you a lot.
I think that should be explained somewhere though, that issue only took me a lot to figure out the cause looking at my tests alone.
That suggested command (DEBUG=knex:tx
) gives no clue at all.
i am not sure, because, to me, it's pretty self explanatory: "Test timeout" is written in bold red in the terminal output
i would suggest seeing if other issues with the same issue open up in the next few weeks/months. if its the case, then we probably could add a quick note in the documentation ?
closing the issue in the meantime, if anyone encounters the same problem, please feel free to re-open it !
thanks again for taking time for giving a reproduction 🤝
About the error
I am using browser client provided by japa to run e2e tests.
I'm tryng to run global transaction for each test on group using the code above:
And i'm having this error:
Using the aproach above is triggering the same error:
Related libs version: