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

Cannot find module when running test on Fargate #2751

Open
madhugod opened this issue May 15, 2024 · 2 comments
Open

Cannot find module when running test on Fargate #2751

madhugod opened this issue May 15, 2024 · 2 comments

Comments

@madhugod
Copy link

madhugod commented May 15, 2024

Version info:

Artillery: 2.0.12
Node.js:   v16.19.1
OS:        win32

Running this command:

artillery run-fargate login/login.yml --region eu-west-1 --count 2 --record --key XXX

I expected to see this happen:

I expect the test to be ran successfully.

Instead, this happened:

But the console says:

Run URL: XXXXXXXX
Checking AWS connectivity... [15:42:29]
Checking cluster... [15:42:30]
Tags: name:login.yml [15:42:30]
Test run ID: XXXXXXXXX [15:42:30]
Preparing launch platform... [15:42:30]
Environment:
  Account:     XXXXXXX
  Region:      eu-west-1
  Count:       2
  Cluster:     artilleryio-cluster
  Launch type: ecs:fargate (On-demand)

Preparing test bundle... [15:42:32]
Test bundle prepared... [15:42:32]
Test bundle contents:
┌──────────────┬──────┬───────┐
│ Name         │ Type │ Notes │
├──────────────┼──────┼───────┤
│ login.yml    │ file │       │
├──────────────┼──────┤       │
│ functions.js │ file │       │
└──────────────┴──────┴───────┘

Launching workers... [15:42:33]
Waiting for Fargate... [15:42:34]
Waiting for workers to start: pending: 2 [15:43:06]
Waiting for workers to start: pending: 2 [15:43:16]
Waiting for workers to start: pending: 2 [15:43:26]
Waiting for workers to start: pending: 2 [15:43:36]
Waiting for workers to come online... [15:43:36]
Workers are running, waiting for reports... [15:43:57]
--------------------------------
Summary report @ 15:44:03(+0200)
--------------------------------

No measurements recorded during this period

And in the CloudWatch logs I can see the following error:

"worker error, id: 1 Error: Cannot find module 'bcrypt'"
Require stack:
'"- /artillery/test_data/functions.js"
'"- /artillery/packages/core/lib/runner.js"
'"- /artillery/packages/core/index.js"
'"- /artillery/packages/artillery/lib/artillery-global.js"
'"- /artillery/packages/artillery/lib/platform/local/worker.js"
    at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
    at Module._load (node:internal/modules/cjs/loader:984:27)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/artillery/test_data/functions.js:1:16)
    at Module._compile (node:internal/modules/cjs/loader:1369:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
    at Module.load (node:internal/modules/cjs/loader:1206:32)
    at Module._load (node:internal/modules/cjs/loader:1022:12)
    at Module.require (node:internal/modules/cjs/loader:1231:19) {
"  code: 'MODULE_NOT_FOUND',"
  requireStack: [
"    '/artillery/test_data/functions.js',"
"    '/artillery/packages/core/lib/runner.js',"
"    '/artillery/packages/core/index.js',"
"    '/artillery/packages/artillery/lib/artillery-global.js',"
    '/artillery/packages/artillery/lib/platform/local/worker.js'
  ]
}
"cleanup called, signal:"
EXIT

Files being used:

- package.json
- package-lock.json
- login/login.yml
- login/functions.js

Note that bcrypt package is installed (in both package.json, package-lock.json and node_modules)

It is also used (via require keyword) in the function.js file that is referenced in the processor field of the login.yml file

@hassy
Copy link
Member

hassy commented May 16, 2024

Very odd, looks like the dependencies are not being discovered as expected. Will try to repro here!

@madhugod
Copy link
Author

madhugod commented May 17, 2024

Did some tests again this morning and I believe this has to do with the fact that the yamls are stored in subfolders.

If I move the yml and js file to the root, I can see all files being bundled.

Test bundle contents:
┌─────────────────────┬─────────┬───────┐
│ Name                │ Type    │ Notes │
├─────────────────────┼─────────┼───────┤
│ login.yml           │ file    │       │
├─────────────────────┼─────────┤       │
│ functions.js        │ file    │       │
├─────────────────────┼─────────┤       │
│ package.json        │ file    │       │
├─────────────────────┼─────────┤       │
│ package-lock.json   │ file    │       │
├─────────────────────┼─────────┼───────┤
│ @types/artillery    │ package │       │
├─────────────────────┼─────────┼───────┤
│ @types/bcrypt       │ package │       │
├─────────────────────┼─────────┼───────┤
│ @types/jsonwebtoken │ package │       │
├─────────────────────┼─────────┼───────┤
│ @types/node         │ package │       │
├─────────────────────┼─────────┼───────┤
│ axios               │ package │       │
├─────────────────────┼─────────┼───────┤
│ bcrypt              │ package │       │
├─────────────────────┼─────────┼───────┤
│ jsonwebtoken        │ package │       │

And everything goes as expected.

Note I had another issue when installing packages (error 401) because my package-lock.json files references our own internal npm repository, which the workers don't have access too because missing the NPM_TOKEN, not sure if their is a solution for this yet, but in my case I didn't use any private package so I just removed the package-lock file in order to let the workers download from the public npmjs repository.

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

No branches or pull requests

2 participants