alexfernandez / loadtest

Runs a load test on the selected URL. Fast and easy to use. Can be integrated in your own workflow using the API.
MIT License
2.55k stars 206 forks source link

Not handling null 'result' value in statusCallback #235

Open TimNZ opened 3 months ago

TimNZ commented 3 months ago

https://github.com/alexfernandez/loadtest/blob/a0f4b30a4d4d44a2699b9d50625ba727e85d277f/lib/pool.js#L75

    finishRequest(client, result, error) {
        if (this.options.statusCallback) {
            result.requestIndex = this.requestIndex++
            result.instanceIndex = this.loadTest.instanceIndex
            this.options.statusCallback(error, result);

In my case 'error' is 'Connection error: connect ECONNREFUSED 127.0.0.1:3007', and result is null, resulting in 'TypeError: Cannot set properties of undefined (setting 'requestIndex')' on setting result.requestIndex

alexfernandez commented 2 months ago

Hi @TimNZ , sorry for the delay. Good catch, care to send a patch?