3

I'm using TypeScript with Nodejs, and I'm testing my MongoDB database with Jest and mongo-memory-server.

I have been using it for some time now (on Arch Linux) and it worked just fine.

Recently I tried WSL (Ubuntu 20.04), and weirdly, when I'm trying to debug any test with mongo-memory-server, it gets stuck immediately, like it's computing something. When I pause, it's on emitHookFactory in async_hooks.js.

Also, mongo_killer.js seems to be running on the call stack.

When I try this on Linux it works just fine again.

What can I do?

EDIT: All the tests pass and the program runs fine, this occurs only when debugging.

EDIT 2: I've noticed something really weird: if I press "Step Over" as quickly as it shows up, the debugger doesn't get stuck, and works fine. I'm using the VSCode debugger by the way.

The Cubear Guy
  • 383
  • 4
  • 17
  • In case this may be relevant, I recently noticed a warning in Mongo docs that it doesn't support WSL. Didn't check further if this means that it cannot be guaranteed to work or that it's known to not work. – Estus Flask Oct 18 '20 at 10:31
  • @EstusFlask Thanks for helping, it seems possible to install mongodb on WSL2, as written in microsoft docs: https://learn.microsoft.com/en-us/windows/wsl/tutorials/wsl-database – The Cubear Guy Oct 18 '20 at 11:17
  • Thanks for the link, I haven't considered WSL2 yet because there were not enough reasons but I probably will because of these concerns. If you were able to sort it out it this way, consider posting a self-answer. There are other answered questions regarding Mongo and WSL but they deal with vanilla installation, not derived packages like mongo-memory-server. – Estus Flask Oct 18 '20 at 11:30
  • @EstusFlask I don't think it's a problem with MongoDB because all the tests work, and the program runs fine with no problems. Also, I've updated the question – The Cubear Guy Oct 18 '20 at 13:44
  • I see. In case the problem is specific to VSCode, try to debug Jest the way it's usually done with Chrome, e.g. https://stackoverflow.com/questions/33247602/how-do-you-debug-jest-tests . – Estus Flask Oct 18 '20 at 18:14

1 Answers1

0

It turns out that using the "Step Over" button in the "Call Stack" menu in the sidebar works.

The Cubear Guy
  • 383
  • 4
  • 17