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

Running Jest now hangs on "Determining test suites to run..." #194

Open
paul-uz opened this issue Feb 21, 2023 · 18 comments
Open

Running Jest now hangs on "Determining test suites to run..." #194

paul-uz opened this issue Feb 21, 2023 · 18 comments

Comments

@paul-uz
Copy link

paul-uz commented Feb 21, 2023

All of a sudden, when trying to run my tests locally, Jest is hanging.

A java process is started on the port I configured, 8000, but it's just taking forever to do anything, in fact on my machine I've simply given up so far.

The same code is ran on Github Actions and that completed in under 30 seconds for all my tests.

@paul-uz
Copy link
Author

paul-uz commented Feb 22, 2023

On my local machine, it seems to be getting stuck in a loop on waitForLocalhost

I have tried setting a new hostname and clientConfig endpoint, but no joy.

Here is the error from request.on('error', retry);

Error: getaddrinfo ENOTFOUND dynamodb
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26)
    at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'dynamodb'
}

@C4n4rd0
Copy link

C4n4rd0 commented Mar 2, 2023

I have the issue except that it's working fine on localhost (windows) and it hangs on starting when running in github actions (Ubuntu) if the node version is 18. If I downgrade the version to 16 or 14, it's working fine on localhost as well as on github actions.

What's your node version and os?

@paul-uz
Copy link
Author

paul-uz commented Mar 2, 2023

@C4n4rd0 hmm I'll have to check, but I think im on v19 locally and have been for some time. But my lambdas mostly run on 16 and 18. I'll try using 16 locally.

My github actions use 16.

@C4n4rd0
Copy link

C4n4rd0 commented Mar 3, 2023

I think I found a workaround. In jest-dynamodb-config.js, in the return statement, I added hostname: '127.0.0.1' and now my tests pass successfully.

@paul-uz
Copy link
Author

paul-uz commented Mar 3, 2023

@C4n4rd0 I tried this, but it didn't work for me. It's still hanging.

module.exports = {
  hostname: '127.0.0.1',
  port: 8000,
};

@paul-uz
Copy link
Author

paul-uz commented Mar 3, 2023

I have just confirmed that everything works fine on Node 16. Node 18+ and it hangs.

@C4n4rd0
Copy link

C4n4rd0 commented Mar 3, 2023

That's strange. Take a look at this: node-fetch/node-fetch#1624

It seems like they have the same issue.

@C4n4rd0
Copy link

C4n4rd0 commented Mar 3, 2023

Finally, I removed what I told you to do previously with 127.0.0.1.

I fixed the issue by adding dns.setDefaultResultOrder('ipv4first') at the beginning of my jest preset.

@paul-uz
Copy link
Author

paul-uz commented Mar 3, 2023

@C4n4rd0 which file is thay exactly?

@C4n4rd0
Copy link

C4n4rd0 commented Mar 3, 2023

Take a look at this page: https://github.com/cjuega/jest-s3

The section "Using with other jest presets".

You have to add a file named "jest-preset.js". This will be the file you have to put as preset ans it's in this file I've put the code relates to dns.

You also have to add 2 files (jest-globalSetup-mix.js and jest-globalTeardown-mix.js) as in the example. The only différence, ils that you only need dynamodb. So you can remove all the code related to s3

@tvanhanen
Copy link

tvanhanen commented Mar 7, 2023

I'm having the same issue with GitHub Actions. Though Jest is just silent. After printing > jest --maxWorkers=2 Jest simply hangs. Also I could reproduce this with Node 16 and 18. On Windows this works locally on Node 18. So my issue may be different.

I tried to setup described by @C4n4rd0, but did not manage to get it working though. Can you pass examples of your configs?

@C4n4rd0
Copy link

C4n4rd0 commented Mar 13, 2023

I read ther might be issues with this max-worker option. An other possibility is to add the option --dns-result-order=ipv4first.
Ex: node --dns-result-order=ipv4first node_modules/.bin/jest ...

@tvanhanen
Copy link

adding to jest-dynamodb-config.js "hostname": "127.0.0.1" in module.exports fixed my issue.

module.exports ={
  "hostname": "127.0.0.1",
  "tables": [.....]
};

@maddiel
Copy link

maddiel commented Jun 20, 2023

That's strange. Take a look at this: node-fetch/node-fetch#1624

It seems like they have the same issue.

based on comments of the node-fetch issue mentioned by @C4n4rd0, I fixed it by adding the following two lines at the top of jest-dynamodb-config.js file

const dns = require('dns')
dns.setDefaultResultOrder('ipv4first')

using v3.4.1 on macOS 13.3.1 (a), NodeJS v18.15.0

@C4n4rd0
Copy link

C4n4rd0 commented Jun 20, 2023

That's strange. Take a look at this: node-fetch/node-fetch#1624

It seems like they have the same issue.

based on comments of the node-fetch issue mentioned by @C4n4rd0, I fixed it by adding the following two lines at the top of jest-dynamodb-config.js file

const dns = require('dns')
dns.setDefaultResultOrder('ipv4first')

using v3.4.1 on macOS 13.3.1 (a), NodeJS v18.15.0

From my point or view, it's clearly the best solution. In Node 16, the default value was ipv4first. From Node 18, the default value is verbatim. This is why we all have this issue.

@abhinav-enboarder
Copy link

Thanks for the solution @C4n4rd0, this does not hang the test runner but I'm getting a timeout error, seems like it can't connect to the DB.

Any suggestions for this config file?

const dns = require('dns');
dns.setDefaultResultOrder('ipv4first');

module.exports = {
    hostname: '127.0.0.1',
    port: 8070,
    tables: [
...

@C4n4rd0
Copy link

C4n4rd0 commented Jun 26, 2023

Can you copy/paste ypur serverless configuration ?

@abhinav-enboarder
Copy link

I'm not using the serverless framework for deployment, it's a simple lambda function talking to DynamoDB. I've tried changing the port and changing the hostname to localhost http://localhost and variations with/out the port number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants