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 excluded from bundling even though package.json is set #3354

Open
sam-barker opened this issue Sep 26, 2024 · 6 comments
Open

Comments

@sam-barker
Copy link

sam-barker commented Sep 26, 2024

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
Copy link
Author

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

@hassy
Copy link
Member

hassy commented Sep 27, 2024

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

@sam-barker
Copy link
Author

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
Copy link
Author

@hassy this is also happening with plain JS as well

@sam-barker
Copy link
Author

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

@hassy
Copy link
Member

hassy commented Oct 1, 2024

@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 [email protected] with anything you find if there's anything potentially sensitive in there.

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