grafana/k6 · error

evaluating pattern: %w

Error message

evaluating pattern: %w

What it means

Error "evaluating pattern: %w" thrown in grafana/k6.

Source

Thrown at internal/js/modules/k6/browser/browser/helpers.go:80

	return args
}

// sobekEmptyString returns true if a given value is not nil or an empty string.
func sobekEmptyString(v sobek.Value) bool {
	return k6common.IsNullish(v) || strings.TrimSpace(v.String()) == ""
}

// newRegExMatcher returns a function that runs in the JS runtime's event loop
// for pattern matching. It uses ECMAScript RegEx engine for consistency.
//
// It's safe to call this function off of the event loop since the returned
// function gets run in the task queue, ensuring it runs on the event loop.
func newRegExMatcher(ctx context.Context, vu moduleVU, tq *taskqueue.TaskQueue) common.RegExMatcher {
	return func(pattern, str string) (bool, error) {
		return queueTask(ctx, tq, func() (bool, error) {
			v, err := vu.Runtime().RunString(pattern + `.test('` + str + `')`)
			if err != nil {
				return false, fmt.Errorf("evaluating pattern: %w", err)
			}
			return v.ToBoolean(), nil
		})()
	}
}

// promise runs fn in a goroutine and returns a new sobek.Promise.
//   - If fn returns a nil error, resolves the promise with the
//     first result value fn returns.
//   - Otherwise, rejects the promise with the error fn returns.
func promise(vu moduleVU, fn func() (result any, reason error)) *sobek.Promise {
	p, resolve, reject := promises.New(vu)
	go func() {
		v, err := fn()
		if err != nil {
			reject(k6ext.BrowserError(err))
			return
		}

View on GitHub (pinned to 93accf6570)

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/browser/helpers.go:80 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/34024e37cad3eadb. Report an issue: GitHub.