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.04k stars 511 forks source link

"Error: Callback was already called" on attempt to send requests in the loop #1909

Closed SDLarmo closed 1 year ago

SDLarmo commented 1 year ago

Version info:

Artillery: 2.0.0-31
Node.js:   v16.17.1
OS:        darwin

Running this command:

artillery run suites/survey.yaml -o ./reports/report.json

I expected to see this happen:

Request must be sent in a loop.

Instead, this happened:

Only the first request is executed, then artillery crashes with an error:

worker error, id: 1 Error: Callback was already called.
    at /Users/serhii/git/tpusa/qa_performance/node_modules/async/dist/async.js:969:32
    at /Users/serhii/git/tpusa/qa_performance/node_modules/@artilleryio/int-core/lib/engine_http.js:702:20
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Files being used:

config:
  target: https://apiurl.net/api/
  timeout: 30000
  processor: "../processors/survey.js"
  payload:
    path: "../payload/users.csv"
    fields:
      - "email"
      - "password"
    order: sequence
  phases:
    - duration: 30
      arrivalCount: 1 
before:
  flow:
    - function: setConfig
scenarios:
  - beforeScenario: "loginByEmail"
    flow:
      - function: prepareContacts
      - loop:
        - post:
            url: "/surveys/{{surveyId}}/results"
            headers:
              Authorization: "Bearer {{ authToken }}"
            json:
              ContactId: "{{ $loopElement }}"
              QuestionId: "{{ questionId }}"
              AnswerId: "{{ answerId }}"
        over: contactIds
bernardobridge commented 1 year ago

Hi @SDLarmo. I've tried to replicate this with a similar setup to yours (using loop, iterating over an array of ids, running a function before the loop, with a CSV), but I cannot replicate your error.

Assuming you're still facing this issue, would you be able to share the custom javascript code you are using (i.e. the contents of processors/survey.js)?

SDLarmo commented 1 year ago

Hi @bernardobridge . The issue was somehow related to using API gateway as a 'target' to use multiple API services in the same test. When I've moved from using 'target' to a direct API URLs for each request - the issue was gone.