Skip to content

Commit

Permalink
fix: allow workers to communicate recoverable errors
Browse files Browse the repository at this point in the history
A worker may encounter an error that does not necessarily require
stopping the execution of a test script, e.g. a local worker may not
be able to load a plugin. The worker can communicate such errors
by setting a "level" property on the workerError message.

This change takes level into account for determining whether the
worker has stopped running or not.

Previous version of this code has a bug, where the stoppedError
state assigned to the worker [1] would get overridden elsewhere
meaning that the condition that determined whether all workers
exited [2] would not evaluate to true as expected. It also had
the same issue of not taking level into account, meaning that
code that handled loading plugins in local worker threads[3] should
have stopped the execution of a test early, but didn't.

1. https://github.com/artilleryio/artillery/blob/1f6e1c6d95d943f1ee6e5ef5b422f8ea70c24b85/packages/artillery/lib/launch-platform.js#L79
2. https://github.com/artilleryio/artillery/blob/1f6e1c6d95d943f1ee6e5ef5b422f8ea70c24b85/packages/artillery/lib/launch-platform.js#L242
3. https://github.com/artilleryio/artillery/blob/1f6e1c6d95d943f1ee6e5ef5b422f8ea70c24b85/packages/artillery/lib/platform/local/worker.js#L160-L167
  • Loading branch information
hassy committed Jul 22, 2024
1 parent bbd4fee commit a378d08
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/artillery/lib/launch-platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ class Launcher {

async initWorkerEvents(workerEvents) {
workerEvents.on('workerError', (workerId, message) => {
this.exitedWorkersCount++;

const { id, error, level, aggregatable, logs } = message;

if (level !== 'warn') {
this.exitedWorkersCount++;
}

if (aggregatable) {
this.workerMessageBuffer.push(message);
} else {
Expand Down

0 comments on commit a378d08

Please sign in to comment.