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.

Jest RANDOMBYTESREQUEST

See original GitHub issue

Describe the bug

uuid is not allowing jest to exit:

Jest has detected the following 1 open handle potentially keeping Jest from exiting:

  ●  RANDOMBYTESREQUEST

      3 | import { UserAuth } from 'src/auth/dto/user.jwt';
      4 | 
    > 5 | export const CurrentUser = createParamDecorator(
        |                            ^
      6 |   (data: unknown, context: ExecutionContext): UserAuth => {
      7 |     const ctx = GqlExecutionContext.create(context);
      8 |     return ctx.getContext().req.user;

      at rng (node_modules/uuid/dist/rng.js:18:21)
      at Object.v4 (node_modules/uuid/dist/v4.js:17:63)
      at Object.createParamDecorator (node_modules/@nestjs/common/decorators/http/create-route-param-metadata.decorator.js:14:30)
      at Object.<anonymous> (src/common/guards/current-user.guard.ts:5:28)

the error is located on https://github.com/uuidjs/uuid/blob/91805f665c38b691ac2cbda56a99231432b00a1a/src/rng.js#L8

How to reproduce

on a Nestjs server just execute:

jest --runInBand --detectOpenHandles

Expected behavior

exit jest without open handlers

Runtime

  • OS: macOs
  • Runtime: Node.js
  • Runtime Version: v15.6.0

Additional information

https://stackoverflow.com/questions/66958699/jest-open-handle-randombytesrequest-on-nestjs-graphql

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

6reactions
jasnellcommented, Apr 7, 2021

Yeah there were recently some changes in this area that may be causing this. I’ll investigate this morning. randomFillSync uses the same underlying mechanism as randomFill but invokes it synchronously. It’s supposed to be marked weak so gc can clean it up immediately after but this error suggests that might not be happening so that’s where I’ll look first.

4reactions
jasnellcommented, Apr 7, 2021

we appreciate your prompt and insightful help on this!

Any time, happy to help 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest and RANDOMBYTESREQUEST open handles
RANDOMBYTESREQUEST issue is in JEST. Initial investigation is in : https://github.com/facebook/jest/issues/11275.
Read more >
jest | Yarn - Package Manager
Jest. Delightful JavaScript Testing. ‍ Developer Ready: Complete and ready to set-up JavaScript testing solution. Works out of the box for...
Read more >
How To Mock uuid In Jest - I Like Kill Nerds
You can create an actual mock module that gets loaded in place of the dependency in your app or you can do it...
Read more >
[Solved]-Jest + Supertest | Jest detecting open handles-node.js
Coding example for the question Jest + Supertest | Jest detecting open ... Jest open handle RANDOMBYTESREQUEST on NestJS GraphQL · Jest did...
Read more >
jest 27.0.0 on Node.js Yarn - NewReleases.io
New release jest version 27.0.0 on Node.js Yarn. ... [jest-core] Do not collect RANDOMBYTESREQUEST as open handles (#11278); [jest-core] Wait briefly for ...
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