artilleryio / artillery

The complete load testing platform. Everything you need for production-grade load tests. Serverless & distributed. Load test with Playwright. Load test HTTP APIs, GraphQL, WebSocket, and more. Use any Node.js module.
https://www.artillery.io
Mozilla Public License 2.0
8.06k stars 511 forks source link

Cannot find module excluded from bundling even though package.json is set #3354

Open sam-barker opened 2 months ago

sam-barker commented 2 months ago

Version info:

latest

Running this command:

artillery run-fargate \
          --region eu-west-1 \
          --dotenv ./.env \
          --cpu $CPU \
          --memory $MEM \
          --max-duration $MAX_DURATION \
          --count $TASK_COUNT \
          --cluster $CLUSTER_NAME \
          --subnet-ids $IDS \
          --security-group-ids $GROUP_IDS \
          --package ./package.json
          ${CONFIG_FILE} \
          --quiet

I expected to see this happen:

Test ran successfully

Instead, this happened: worker error, id: 2 Error: Cannot find module 'winston'

Even though I have this in the package json, and I have specified the package json in the artillery arguments.

If I remove the bundling config

bundling:
    external: ['playwright', 'winston']

Then it just moans about marking the module as external, so it's an endless cycle.

Files being used:

config:
  target: "https://www.dunelm.com"
  phases:
    - duration: 10m
      arrivalRate: 1
      maxVusers: 1
      name: step_1
  engines:
    playwright:
      contextOptions:
        userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 PE"
      aggregateByName: true
      launchOptions:
        headless: true
  processor: ../../index.ts
  bundling:
    external: ['playwright', 'winston']
scenarios: ...blah
sam-barker commented 1 month ago

@bernardobridge @hassy any ideas or clues for this once? I really don't want to have to go back to JS + Webpack :(

hassy commented 1 month ago

I'll try to reproduce locally. Does winston get loaded by your TypeScript code directly, or indirectly via another dependency?

sam-barker commented 1 month ago

I'll try to reproduce locally. Does winston get loaded by your TypeScript code directly, or indirectly via another dependency?

Hey @hassy it's via our TypeScript code, we import it directly as a node module.

It moans about many others as well that we include as a node module, but for simplicities sake I just mentioned winston in the bug

sam-barker commented 1 month ago

@hassy this is also happening with plain JS as well

sam-barker commented 1 month ago

@hassy it looks like the node_modules zip created by the leader is completely empty

hassy commented 1 month ago

@sam-barker We'll need to look at the worker logs in CloudWatch to see what's happening. node_modules zip being empty means something is going wrong with the installation of dependencies. (I've tried reproducing with a simple test that uses custom TypeScript code with winston as well and that works as expected.)

You can find a worker's CloudWatch log either in the AWS Console, via Elastic Container Service -> Clusters -> your cluster -> Tasks -> a running/stopped Artillery task -> Logs. Or if you're using Artillery Cloud, there will be a link directly to CloudWatch logs under Logs -> Worker logs:

CleanShot 2024-10-01 at 11 59 10

Feel free to email me on hveldstra@artillery.io with anything you find if there's anything potentially sensitive in there.