Skip to content

Commit

Permalink
Fix race in http.batch after latest goja update (#3346)
Browse files Browse the repository at this point in the history
* Fix race in http.batch after latest goja update

Previous http.batch code did call `runtime.NewArrayBuffer` concurrently.

Which never has been guaranteed to be safe, but with the latest goja
changes to having prototypes created on demand it races.

The fix *might* have some performance implications, but they are likely
to be very small as `NewArrayBuffer` mostly wraps stuff so ... hopefully
not a big deal.

Fixes #3345

* Update js/modules/k6/http/request.go

Co-authored-by: Oleg Bespalov <[email protected]>
  • Loading branch information
mstoykov and olegbespalov authored Sep 21, 2023
1 parent 3655065 commit d1c5ee8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 5 additions & 0 deletions js/modules/k6/http/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,11 @@ func (c *Client) Batch(reqsV ...goja.Value) (interface{}, error) {
err = e
}
}
for _, req := range batchReqs {
if req.Response != nil {
c.processResponse(req.Response, req.ParsedHTTPRequest.ResponseType)
}
}
return results, err
}

Expand Down
1 change: 0 additions & 1 deletion lib/netext/httpext/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func MakeBatchRequests(

resp, err := MakeRequest(ctx, state, req.ParsedHTTPRequest)
if resp != nil {
processResponse(resp, req.ParsedHTTPRequest.ResponseType)
*req.Response = *resp
}
result <- err
Expand Down

0 comments on commit d1c5ee8

Please sign in to comment.