{"record":{"id":"34024e37cad3eadb","repo":"grafana/k6","slug":"evaluating-pattern-w","errorCode":null,"errorMessage":"evaluating pattern: %w","messagePattern":"evaluating pattern: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/helpers.go","lineNumber":80,"sourceCode":"\treturn args\n}\n\n// sobekEmptyString returns true if a given value is not nil or an empty string.\nfunc sobekEmptyString(v sobek.Value) bool {\n\treturn k6common.IsNullish(v) || strings.TrimSpace(v.String()) == \"\"\n}\n\n// newRegExMatcher returns a function that runs in the JS runtime's event loop\n// for pattern matching. It uses ECMAScript RegEx engine for consistency.\n//\n// It's safe to call this function off of the event loop since the returned\n// function gets run in the task queue, ensuring it runs on the event loop.\nfunc newRegExMatcher(ctx context.Context, vu moduleVU, tq *taskqueue.TaskQueue) common.RegExMatcher {\n\treturn func(pattern, str string) (bool, error) {\n\t\treturn queueTask(ctx, tq, func() (bool, error) {\n\t\t\tv, err := vu.Runtime().RunString(pattern + `.test('` + str + `')`)\n\t\t\tif err != nil {\n\t\t\t\treturn false, fmt.Errorf(\"evaluating pattern: %w\", err)\n\t\t\t}\n\t\t\treturn v.ToBoolean(), nil\n\t\t})()\n\t}\n}\n\n// promise runs fn in a goroutine and returns a new sobek.Promise.\n//   - If fn returns a nil error, resolves the promise with the\n//     first result value fn returns.\n//   - Otherwise, rejects the promise with the error fn returns.\nfunc promise(vu moduleVU, fn func() (result any, reason error)) *sobek.Promise {\n\tp, resolve, reject := promises.New(vu)\n\tgo func() {\n\t\tv, err := fn()\n\t\tif err != nil {\n\t\t\treject(k6ext.BrowserError(err))\n\t\t\treturn\n\t\t}","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/helpers.go#L62-L98","documentation":"Error \"evaluating pattern: %w\" thrown in grafana/k6.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/browser/helpers.go:80 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}