artillery icon indicating copy to clipboard operation
artillery copied to clipboard

unhandled promise rejection on Before and After sections

Open robinComa opened this issue 2 years ago • 0 comments

Hello,

Requests on the before and after section have unhandled promise rejection. When the request is in timeout for exemple the subprocess don't stop correclty.

Here an exemple :

config:
  ...
  http:
    timeout: 10
 ...
before:
  beforeScenario: "useDate"
  flow:
    - log: "* GET /api/auth/login"
    - post:
        url: "/api/auth/login"
        json:
          login: "{{login}}"
          password: "{{password}}"
        capture:
          - json: $.token
            as: "token"
    - log: "Bearer token : {{token}}"
after:
  flow:
    - log: "* DELETE /api/auth/logout"
    - delete:
        url: "/api/auth/logout"
scenarios:
  - flow:
    - get:
        url: "/"
        headers:
          authorization: "Bearer {{ token }}"
        expect:
          - statusCode: 200

Sometimes the login or logout is in timeout (or something wrong, status >= 400) and the process stop with this log :

* DELETE /api/auth/logout
(node:761) UnhandledPromiseRejectionWarning: RequestError: Timeout awaiting 'request' for 10000ms
    at ClientRequest.<anonymous> (/node_modules/got/dist/source/core/index.js:962:65)
    at Object.onceWrapper (events.js:422:26)
    at ClientRequest.emit (events.js:327:22)
    at ClientRequest.origin.emit (/node_modules/@szmarczak/http-timer/dist/source/index.js:43:20)
    at TLSSocket.socketErrorListener (_http_client.js:469:9)
    at TLSSocket.emit (events.js:327:22)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
    at Timeout.timeoutHandler [as _onTimeout] (/node_modules/got/dist/source/core/utils/timed-out.js:36:25)
    at listOnTimeout (internal/timers.js:556:17)
    at processTimers (internal/timers.js:497:7)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:761) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:761) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

All process is stopped, and artillery don't run anymore.

PS : the expect plugin seems not working on before and after section

Versions :

  • node : v14.17.6
  • npm : 6.14.15
  • artillery : 2.0.0-11
  • artillery-plugin-expect : 2.0.0-3

robinComa avatar Feb 23 '22 09:02 robinComa