Skip to content

Commit ec1f601

Browse files
committed
js/modules: update docs around NewModuleInstance
The previous comment made it seem that for each invocation of `require` or `import` it will be called for each VU. While it only gets called on the first `require`/`import`. While this is only gets called the first time it is required for each VU that `imports`/`require`
1 parent 135f85b commit ec1f601

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

js/modules/modules.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strings"
88

99
"github.com/grafana/sobek"
10+
1011
"go.k6.io/k6/ext"
1112
"go.k6.io/k6/js/common"
1213
"go.k6.io/k6/lib"
@@ -27,8 +28,8 @@ func Register(name string, mod interface{}) {
2728

2829
// Module is the interface js modules should implement in order to get access to the VU
2930
type Module interface {
30-
// NewModuleInstance will get modules.VU that should provide the module with a way to interact with the VU
31-
// This method will be called for *each* require/import and should return an unique instance for each call
31+
// NewModuleInstance will get modules.VU that should provide the module with a way to interact with the VU.
32+
// This method will be called for *each* VU that imports the module *once* per that VU.
3233
NewModuleInstance(VU) Instance
3334
}
3435

0 commit comments

Comments
 (0)