question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I’m submitting this issue because I believe there to be a problem with the test suite that is really hindering the contributor developer experience, plus there could be a more serious underlying problem that could be causing this.

I don’t believe the specs on my machine to be amazing but nor do I believe them to be low end and I have run test suites, including integrations, of similar size before with no problem.

I’m using the provided docker-compose file in the docker dir. - This is using about 2GB of ram.

When running the tests in the client dir for example:

$ cd ./packages/client && pnpm run test

I first get a bunch of successful tests and then a warning stating that something has not been awaited:

 PASS  src/__tests__/integration/errors/referentialActions-onDelete-default-foreign-key-error-postgresql/test.ts
 PASS  src/__tests__/integration/happy/client-engine/test.ts (26.568 s)
 PASS  src/__tests__/integration/happy/blog-env-cockroachdb/test.ts
 PASS  src/__tests__/integration/errors/can-not-connect-to-database/test.ts (10.924 s)
 PASS  src/__tests__/integration/errors/int-errors/test.ts
 PASS  src/__tests__/integration/happy/blog/test.ts
 PASS  src/__tests__/integration/errors/referentialActions-onDelete-default-foreign-key-error-sqlite/test.ts
 PASS  src/__tests__/integration/happy/blog-dot-env-both/test.ts
 PASS  src/__tests__/integration/errors/corruption/test.ts
 PASS  src/__tests__/integration/happy/blog-dot-env-root/test.ts
 PASS  src/__tests__/integration/errors/missing-engine-native-binaryTarget/library.test.ts
 PASS  src/__tests__/integration/errors/executeRaw-alter-postgres/test.ts
 PASS  src/__tests__/integration/happy/blog-dot-env-both-conflict/test.ts
 PASS  src/__tests__/integration/happy/blog-dot-env-prisma/test.ts
 PASS  src/__tests__/integration/happy/binary/test.ts
 PASS  src/__tests__/integration/happy/createMany-postgresql/test.ts
 PASS  src/__tests__/integration/happy/custom-engine-binary/test.ts
 PASS  src/__tests__/integration/errors/wrong-native-types-postgres/test.ts
 PASS  src/__tests__/integration/errors/missing-engine/library.test.ts
 PASS  src/__tests__/integration/happy/createMany-mysql/test.ts
 PASS  src/__tests__/integration/happy/browser/test.ts
 PASS  src/__tests__/integration/happy/chaining/test.ts
 PASS  src/__tests__/integration/errors/invalid-url/test.ts
 PASS  src/__tests__/integration/errors/incorrect-column-type/test.ts
 PASS  src/__tests__/integration/errors/wrong-native-types-mysql/test.ts
 PASS  src/__tests__/integration/errors/source-map-support/test.ts
 PASS  src/__tests__/integration/errors/client-version-error/test.ts
 PASS  src/__tests__/deepSome.test.ts
 PASS  src/__tests__/integration/errors/union-validation/test.ts
 PASS  src/__tests__/binaryEngine.test.ts
 PASS  src/__tests__/integration/errors/error-link/test.ts
 PASS  src/__tests__/integration/happy/batch-findUnique/test.ts
 PASS  src/__tests__/integration/errors/uncheckedScalarValidation/test.ts
 PASS  src/__tests__/integration/errors/object-transaction/test.ts
 PASS  src/__tests__/integration/happy/count/test.ts
 PASS  src/__tests__/atLeastOne.test.ts
 PASS  src/__tests__/validatePrismaClientOptions.test.ts
 PASS  src/__tests__/deepAndOr.test.ts
 PASS  src/__tests__/dateWhere.test.ts
 PASS  src/__tests__/dmmfTypes.test.ts
 PASS  src/__tests__/buildNFTAnnotations.test.ts
 PASS  src/__tests__/integration/errors/missing-engine-native-binaryTarget/binary.test.ts
 PASS  src/__tests__/batching.test.ts
 PASS  src/__tests__/dmmf.test.ts
 PASS  src/__tests__/integration/happy/blog-update/test.ts
 PASS  src/__tests__/integration/errors/missing-table/test.ts
 PASS  src/__tests__/integration/errors/invalid-input/test.ts
 PASS  src/__tests__/select.test.ts
 PASS  src/__tests__/minimalWhereTransformation.test.ts
 PASS  src/__tests__/integration/errors/color-format/test.ts
 PASS  src/__tests__/integration/errors/too-many-instances-of-prisma-client/test.ts
 PASS  src/__tests__/integration/happy/aggregations/test.ts
 PASS  src/__tests__/integration/happy/blog-env/test.ts
 PASS  src/__tests__/relationWhereTransformation.test.ts
 PASS  src/__tests__/integration/happy/disconnect-finally/test.ts
 PASS  src/__tests__/integration/errors/missing-engine/binary.test.ts
 PASS  src/__tests__/integration/errors/raw-transaction/test.ts
 PASS  src/__tests__/integration/errors/missing-column/test.ts
 PASS  src/__tests__/unpack.test.ts
 PASS  src/__tests__/integration/happy/atomic-operations/test.ts
 PASS  src/__tests__/orderTransformation.test.ts
 PASS  src/__tests__/integration/errors/missing-relation/test.ts
 PASS  src/__tests__/or.test.ts
 PASS  src/__tests__/noArgs.test.ts
 PASS  src/__tests__/singularRelationWhereTransformation.test.ts
 PASS  src/__tests__/atomicOperationsUpdate.test.ts
 PASS  src/__tests__/deepQuery.test.ts
 PASS  src/__tests__/relationWhereORNotNullTransformation.test.ts
 PASS  src/__tests__/update.test.ts
 PASS  src/__tests__/undefined-vs-null.test.ts
 PASS  src/__tests__/optionalRelation.test.ts
 PASS  src/__tests__/include.test.ts
 PASS  src/__tests__/scalarWhereTransformation.test.ts
 PASS  src/__tests__/uuid.test.ts
 PASS  src/__tests__/extractSqliteSources.test.ts
 PASS  src/__tests__/scripts/postinstall.test.ts
 PASS  src/__tests__/scalarListCreate.test.ts
 PASS  src/__tests__/deepGet.test.ts
 PASS  src/__tests__/serializeRawParameters.test.ts

  ●  Cannot log after tests are done. Did you forget to wait for something async in your test?
    Attempted to log "warning In order to use "@prisma/client", please install Prisma CLI. You can install it with "npm add -D prisma".".

      93 |
      94 |   if (!localPath && !installedGlobally) {
    > 95 |     console.error(
         |             ^
      96 |       `${c.yellow(
      97 |         'warning',
      98 |       )} In order to use "@prisma/client", please install Prisma CLI. You can install it with "npm add -D prisma".`,

      at console.error (../../node_modules/.pnpm/@jest+console@27.5.1/node_modules/@jest/console/build/BufferedConsole.js:163:10)
      at main (scripts/postinstall.js:95:13)

Shortly after this, I’m getting a few more passing tests then an error stating that there is many instances of Prisma client constructed:

PASS  src/__tests__/aggregate.test.ts
 PASS  src/__tests__/resolveDatasources.test.ts
 PASS  src/__tests__/document.test.ts
 PASS  src/__tests__/mergeBy.test.ts
 PASS  src/__tests__/getLogLevel.test.ts
 PASS  src/__tests__/integration/happy/async-hooks/test.ts
 PASS  src/__tests__/integration/happy/signals/test.ts
 PASS  src/__tests__/integration/happy/logging/library.ts
 PASS  src/__tests__/integration/happy/sqlite-variable-limit/test.ts (6.585 s)
 PASS  src/__tests__/integration/happy/logging/binary.ts
 PASS  src/__tests__/integration/happy/referentialActions-onDelete-cascade-mysql/test.ts
 PASS  src/__tests__/integration/happy/referentialActions-onDelete-cascade-postgresql/test.ts
 PASS  src/__tests__/integration/happy/json-filtering-postgres/test.ts
 PASS  src/__tests__/integration/happy/native-types-mysql/test.ts
 PASS  src/__tests__/integration/happy/interactive-transactions-postgres/test.ts (23.57 s)
  ● Console

    console.warn
      warn(prisma-client) There are already 10 instances of Prisma Client actively running.

      81 |       const runningEngines = engines.filter((e) => e.engine);
      82 |       if (runningEngines.length === 10) {
    > 83 |         console.warn(`${import_chalk.default.yellow("warn(prisma-client)")} There are already 10 instances of Prisma Client actively running.`);
         |                 ^
      84 |       }
      85 |     }
      86 |   }

      at LibraryEngine.checkForTooManyEngines (../engine-core/dist/library/LibraryEngine.js:83:17)
      at new LibraryEngine (../engine-core/dist/library/LibraryEngine.js:77:10)
      at PrismaClient.getEngine (src/runtime/getPrismaClient.ts:454:47)
      at new PrismaClient (src/runtime/getPrismaClient.ts:425:29)
      at Object.<anonymous> (src/__tests__/integration/happy/interactive-transactions-postgres/test.ts:658:12)

 PASS  src/__tests__/integration/happy/native-types-postgres/test.ts (19.823 s)
 PASS  src/__tests__/integration/happy/json-filtering-mysql/test.ts (27.959 s)
 PASS  src/__tests__/types/types.test.ts (426.401 s)
 FAIL  src/__tests__/integration/happy/composites-mongo/upsert/required/create.ts (473.354 s)
  ● upsert > required > create › set

    thrown: "Exceeded timeout of 90000 ms for a hook.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

      18 |   })

It’s at this point when the tests completely stop my machine(100%cpu, 100%ram) and hang for a unknown amount of time sometimes > 1 hour.

I can’t trust the location of the warnings because of the way jest is rendering the console logs, and so it’s really unknown where this error is happening.

I have tried running the tests with --maxWorkers=50% to no avail:

PC Specs

Running tests with Gitbash

image

Related

Some issues I dug out that could be related to this.

  1. https://github.com/prisma/prisma/issues/8989
  2. https://github.com/prisma/prisma/issues/7249
  3. https://github.com/prisma/prisma/issues/12858
  4. https://github.com/prisma/prisma/issues/9902
  5. https://github.com/prisma/prisma/issues/12028
  6. https://github.com/prisma/prisma/issues/9042

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
SevInfcommented, Jul 15, 2022

I beleive this should be fixed right now. iTx caused the slowdown. Issue was fixed in prisma/prisma-engines#3028

1reaction
janpiocommented, May 3, 2022

Side note: Instructions on how to install direnv on Windows that worked for me: https://gist.github.com/rmtuckerphx/4ace28c1605300462340ffa7b7001c6d

Read more comments on GitHub >

github_iconTop Results From Across the Web

9 Ways To Make Slow Tests Faster - Semaphore CI
At Semaphore, we've seen our fair share of tests and have identified 9 ways to make your slow tests faster.
Read more >
Slow Tests at XUnitPatterns.com
Slow Tests can be caused by either the way the SUT is built and tested or by the way the tests are designed....
Read more >
Fast fixes for slow tests: How to unclog your CI pipeline
It's common that slow tests are overloaded—they try to do too many things. By paring down the steps each test has to perform,...
Read more >
Slow Tests | DevLead.io
Common causes for long running tests include over-engineered test fixtures, asynchronous code, components with high latency, Test Overlap, and ...
Read more >
Chapter 22. Fast Tests, Slow Tests, and Hot Lava - O'Reilly
Chapter 22. Fast Tests, Slow Tests, and Hot Lava The database is Hot Lava! — Casey Kinsey Right up until Chapter 19, almost...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found