grafana/k6 · error
cannot do key up
Error message
cannot do key up: %w
What it means
Wrap of Keyboard.up inside Keyboard.comboPress: after all combo keys were pressed, keys are released in reverse order, and this wrap means one of the releases failed. Because the corresponding down already succeeded, the usual cause is the CDP dispatch failing mid-sequence (session closed or context canceled between press and release), though an invalid key name would also surface here if the up path re-validates it.
Solutions
- Avoid tearing down the page or ending the iteration between press and release
- Ensure combo key names are valid so both down and up succeed
- Rely on press() to keep the down/up pair atomic
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/keyboard.go:277 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/cd9c9158b085bf9f.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/keyboard.go:277
func (k *Keyboard) comboPress(keys string, opts KeyboardOptions) error {
if opts.Delay > 0 {
if err := wait(k.ctx, opts.Delay); err != nil {
return err
}
}
kk := split(keys)
for _, key := range kk {
if err := k.down(key); err != nil {
return fmt.Errorf("cannot do key down: %w", err)
}
}
for i := range kk {
key := kk[len(kk)-i-1]
if err := k.up(key); err != nil {
return fmt.Errorf("cannot do key up: %w", err)
}
}
return nil
}
// This splits the string on `+`.
// If `+` on it's own is passed, it will return ["+"].
// If `++` is passed in, it will return ["+", ""].
// If `+++` is passed in, it will return ["+", "+"].
func split(keys string) []string {
var (
kk = make([]string, 0)
s strings.Builder
)
for _, r := range keys {
if r == '+' && s.Len() > 0 {
kk = append(kk, s.String())View on GitHub (pinned to 01ffac6f24)