{"record":{"id":"20cb7d6fc9b7e408","repo":"grafana/k6","slug":"dispatching-key-event-up-w","errorCode":null,"errorMessage":"dispatching key event up: %w","messagePattern":"dispatching key event up: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/keyboard.go","lineNumber":160,"sourceCode":"\tkeyInput := keyboardlayout.KeyInput(key)\n\tif _, ok := k.layout.ValidKeys[keyInput]; !ok {\n\t\treturn fmt.Errorf(\"'%s' is not a valid key for layout '%s'\", key, k.layoutName)\n\t}\n\n\tkeyDef := k.keyDefinitionFromKey(keyInput)\n\tk.modifiers &= ^k.modifierBitFromKeyName(keyDef.Key)\n\tk.pressedKeysMu.Lock()\n\tdelete(k.pressedKeys, keyDef.KeyCode)\n\tk.pressedKeysMu.Unlock()\n\n\taction := input.DispatchKeyEvent(input.KeyUp).\n\t\tWithModifiers(input.Modifier(k.modifiers)).\n\t\tWithKey(keyDef.Key).\n\t\tWithWindowsVirtualKeyCode(keyDef.KeyCode).\n\t\tWithCode(keyDef.Code).\n\t\tWithLocation(keyDef.Location)\n\tif err := action.Do(cdp.WithExecutor(k.ctx, k.session)); err != nil {\n\t\treturn fmt.Errorf(\"dispatching key event up: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (k *Keyboard) insertText(text string) error {\n\taction := input.InsertText(text)\n\tif err := action.Do(cdp.WithExecutor(k.ctx, k.session)); err != nil {\n\t\treturn fmt.Errorf(\"inserting text: %w\", err)\n\t}\n\treturn nil\n}\n\nfunc (k *Keyboard) keyDefinitionFromKey(key keyboardlayout.KeyInput) keyboardlayout.KeyDefinition {\n\tshift := k.modifiers & ModifierKeyShift\n\n\t// Find directly from the keyboard layout\n\tsrcKeyDef, ok := k.layout.Keys[key]","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/keyboard.go#L142-L178","documentation":"Wrap of the CDP Input.dispatchKeyEvent (keyUp) command inside Keyboard.up: layout validation already passed and the key was removed from the pressed-keys/modifier tracking, so this wrap indicates the protocol dispatch failed — the session or context was closed (page navigating, test iteration ending) at the moment the release event was sent.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/keyboard.go:160 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Release keys before closing or navigating away from the page","Use press() so down and up happen back-to-back within one live session","Retry on a fresh page if the session died unexpectedly"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}