Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test/fix(client): await blocking IO #13169

Closed
wants to merge 4 commits into from

Conversation

danstarns
Copy link
Contributor

@danstarns danstarns commented May 4, 2022

Awaits blocking IO in client/integration tests:

Related: #13092

await prisma.$disconnect()
})

test('engines', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you merged this into a single test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed this back to what it was before. I initially changed this test because when running the test it I get:

(node:39400) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
(node:39400) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGTERM listeners added to [process]. Use emitter.setMaxListeners() to increase limit

Then secondly because its running all theses tests sequentially:

client engine
    √ expects(binary) | PRISMA_CLIENT_ENGINE_TYPE=binary | engineType=binary (2585 ms)
    √ expects(library) | PRISMA_CLIENT_ENGINE_TYPE=library | engineType=binary (1641 ms)
    √ expects(binary) | PRISMA_CLIENT_ENGINE_TYPE=undefined | engineType=binary (1953 ms)
    √ expects(binary) | PRISMA_CLIENT_ENGINE_TYPE=binary | engineType=library (1954 ms)
    √ expects(library) | PRISMA_CLIENT_ENGINE_TYPE=library | engineType=library (1547 ms)
    √ expects(library) | PRISMA_CLIENT_ENGINE_TYPE=undefined | engineType=library (1538 ms)
    √ expects(binary) | PRISMA_CLIENT_ENGINE_TYPE=binary | engineType=undefined (1955 ms)
    √ expects(library) | PRISMA_CLIENT_ENGINE_TYPE=library | engineType=undefined (1596 ms)
    √ expects(library) | PRISMA_CLIENT_ENGINE_TYPE=undefined | engineType=undefined (1544 ms)

each making more than three calls to disk for each test.

@janpio
Copy link
Member

janpio commented May 5, 2022

Potentially stupid question: What is the difference of these to how it was run before?

@Jolg42 Jolg42 added this to the 3.14.0 milestone May 9, 2022
Comment on lines +21 to +22
beforeAll(async () => {
await fs.promises.copyFile(path.join(__dirname, 'dev.db'), path.join(__dirname, 'dev2.db'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably doesn't matter in this case. Technically it'll even be kinda slower because of the overhead of creating a new task on the thread pool and then just waiting for it without doing anything else on the main thread (since there shouldn't be anything else running concurrently with the beforeAll hook in one Jest worker), but the difference should be negligible.

@aqrln
Copy link
Member

aqrln commented May 10, 2022

@janpio

Potentially stupid question: What is the difference of these to how it was run before?

I don't think there should be any observable difference in these cases, since all of these changes are in tests, and Jest only parallelises tests across multiple workers (separate Node.js processes each with their own event loop), it doesn't run tests concurrently in a single worker[1]. So what I wrote in a previous comment really applies to all or most of these changes to a certain extent, but in functions that are already async it still makes total sense at least as a stylistic change.


[1]At least it tries not to, but sometimes, e.g., some leftover async tasks may be executing after a test times out.

@aqrln
Copy link
Member

aqrln commented May 10, 2022

it doesn't run tests concurrently in a single worker

Or, rather, it shouldn't. If it somehow does on @danstarns's machine, it may be the reason behind #13092

@aqrln aqrln modified the milestones: 3.14.0, 3.15.0 May 10, 2022
@danstarns danstarns closed this Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants