Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion internal/js/jsmodules.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package js

import (
"errors"
"sync"

"go.k6.io/k6/ext"
"go.k6.io/k6/internal/js/modules/k6"
Expand Down Expand Up @@ -49,10 +50,15 @@ func getInternalJSModules() map[string]interface{} {
// Experimental modules
"k6/experimental/csv": csv.New(),
"k6/experimental/fs": fs.New(),
"k6/experimental/redis": redis.New(),
"k6/experimental/streams": streams.New(),
"k6/experimental/websockets": expws.New(),

// Deprecated modules
"k6/experimental/redis": newWarnExperimentalModule(redis.New(),
"k6/experimental/redis has been deprecated and will be removed in future versions."+
" Please migrate to the new version by changing your import to 'k6/x/redis'."+
" Read more here: https://grafana.com/docs/k6/latest/javascript-api/k6-x/redis"),
Copy link
Contributor Author

@codebien codebien Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
" Read more here: https://grafana.com/docs/k6/latest/javascript-api/k6-x/redis"),
" Read more here: https://grafana.com/docs/k6/latest/javascript-api/redis"),

This is an invented path. For now, we aren't hosting any documentation of official extensions on grafana.com/docs. I guess we don't want to drop the documentation for redis from the official docs so we need to find a new home for it.

The current experiemental documentation is here https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/redis/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This aligns with the approach I took with the dns extension's docs so far.

In xk6-dns, I used: docs/sources/k6/next/javascript-api/k6-x-dns/_index.md as a format, because my preferred approach was to treat extensions as first class citizens in the docs. Not distinguish them from modules. Simply adding a common "admonition" (I think that's how they're called, at the top mentioning that the following module is an extension (as users need to know, but it concretely doesn't change much to their usage in practice).

I wouldn't mind putting it in a separate folder like you're doing here though.


// Removed modules
"k6/experimental/browser": newRemovedModule(
"k6/experimental/browser has been graduated, please use k6/browser instead." +
Expand Down Expand Up @@ -101,3 +107,22 @@ func (rm *removedModule) NewModuleInstance(vu modules.VU) modules.Instance {

return nil
}

type warnExperimentalModule struct {
once sync.Once
msg string
base modules.Module
}

func newWarnExperimentalModule(base modules.Module, msg string) modules.Module {
return &warnExperimentalModule{
msg: msg,
base: base,
once: sync.Once{},
Copy link
Contributor

@inancgumus inancgumus Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this now (line 121) 🎉

}
}

func (w *warnExperimentalModule) NewModuleInstance(vu modules.VU) modules.Instance {
w.once.Do(func() { vu.InitEnv().Logger.Warn(w.msg) })
return w.base.NewModuleInstance(vu)
}
Loading