Skip to content

fix: pass exitCode to beforeExit extension in run-fargate#3674

Open
RohanHandore wants to merge 1 commit intoartilleryio:mainfrom
RohanHandore:fix/slack-plugin-fargate-exit-code-3588
Open

fix: pass exitCode to beforeExit extension in run-fargate#3674
RohanHandore wants to merge 1 commit intoartilleryio:mainfrom
RohanHandore:fix/slack-plugin-fargate-exit-code-3588

Conversation

@RohanHandore
Copy link

@RohanHandore RohanHandore commented Jan 16, 2026

Description

This PR fixes a bug where the Slack plugin incorrectly reported "Failed" status for successful artillery run-fargate test runs. The issue occurred because the beforeExit extension was not receiving the exitCode parameter when called from the gracefulShutdown function in run-cluster.js.

Problem

When running tests with artillery run-fargate, the Slack plugin would show "🔴 Artillery test run failed" even when tests completed successfully. This was because:

  1. The gracefulShutdown function in run-cluster.js calls the beforeExit extension without passing exitCode and earlyStop parameters
  2. The Slack plugin relies on opts.exitCode to determine success/failure status
  3. Without exitCode, the plugin falls back to global.artillery.suggestedExitCode, which may be incorrectly set from worker errors

Solution

Added exitCode and earlyStop parameters to the beforeExit extension call in gracefulShutdown, matching the pattern used in the regular run command (packages/artillery/lib/cmds/run.js).

Changes

  • Modified: packages/artillery/lib/platform/aws-ecs/legacy/run-cluster.js

    • Added exitCode: opts.exitCode and earlyStop: opts.earlyStop to the beforeExit extension call (lines 524-525)
  • Added: packages/artillery/test/unit/before-exit-exitcode.test.js

    • New unit test to verify beforeExit extension receives exitCode correctly
    • Tests successful runs (exitCode: 0), failed runs (exitCode: 1), and early stop scenarios

Testing

  • ✅ All existing unit tests pass (144 tests)
  • ✅ New test verifies the fix works correctly
  • ✅ No linting errors

Impact

After this fix, the Slack plugin will correctly report:

  • 🟢 "Artillery test run finished" for successful Fargate runs
  • 🔴 "Artillery test run failed" for failed Fargate runs

This ensures consistency between Slack notifications and the Artillery Cloud dashboard status.

Closes #3588

Pre-merge checklist

This is for use by the Artillery team. Please leave this in if you're contributing to Artillery.

  • Does this require an update to the docs?
  • Does this require a changelog entry?

Add exitCode and earlyStop parameters to beforeExit extension call
in run-cluster.js gracefulShutdown function. This fixes the bug where
Slack plugin incorrectly reported failures for successful Fargate runs.

Fixes artilleryio#3588
@CLAassistant
Copy link

CLAassistant commented Jan 16, 2026

CLA assistant check
All committers have signed the CLA.

@hassy
Copy link
Member

hassy commented Jan 21, 2026

thanks for taking the time @RohanHandore but I'm not sure this actually fixes an issue.

Passing exitCode in the arguments won't do anything since global.artillery.suggestedExitCode has priority: https://github.com/artilleryio/artillery/blob/main/packages/artillery-plugin-slack/index.js#L88

Moreover a worker failure should in fact mark the test as unsuccessful, so existing behavior would be correct.

The new test tests itself rather than the actual functionality too.

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

Successfully merging this pull request may close these issues.

Slack plugin reports "Artillery test run failed" message while Artillery Cloud dashboard shows "Succeeded" status

3 participants