JanDeDobbeleer/oh-my-posh · error

await RequestAsync: %w

Error message

await RequestAsync: %w

What it means

After RequestAsync starts, queryMediaPlayer polls the IAsyncOperation status via awaitAsync. If the operation completes as canceled/failed or times out (smtcAsyncTimeout), awaitAsync returns an error which is wrapped as "await RequestAsync: %w". The SMTC session list could not be retrieved in time or failed.

Source

Thrown at src/runtime/smtc_windows.go:257

	var factory unsafe.Pointer
	hr, _, _ = procRoGetActivationFactory.Call(
		uintptr(classID),
		uintptr(unsafe.Pointer(&iidSMTCSessionManagerStatics)),
		uintptr(unsafe.Pointer(&factory)),
	)
	if hr != 0 {
		return nil, fmt.Errorf("RoGetActivationFactory: 0x%08x", hr)
	}
	defer comRelease(factory)

	var asyncOp unsafe.Pointer
	if hr := comCall(factory, staticsRequestAsync, uintptr(unsafe.Pointer(&asyncOp))); hr != 0 {
		return nil, fmt.Errorf("RequestAsync: 0x%08x", hr)
	}
	defer comRelease(asyncOp)

	if err := awaitAsync(asyncOp); err != nil {
		return nil, fmt.Errorf("await RequestAsync: %w", err)
	}

	var manager unsafe.Pointer
	if hr := comCall(asyncOp, asyncOpGetResults, uintptr(unsafe.Pointer(&manager))); hr != 0 {
		return nil, fmt.Errorf("GetResults manager: 0x%08x", hr)
	}
	defer comRelease(manager)

	var sessions unsafe.Pointer
	if hr := comCall(manager, managerGetSessions, uintptr(unsafe.Pointer(&sessions))); hr != 0 {
		return nil, fmt.Errorf("GetSessions: 0x%08x", hr)
	}
	defer comRelease(sessions)

	var size uint32
	if hr := comCall(sessions, vectorViewGetSize, uintptr(unsafe.Pointer(&size))); hr != 0 {
		return nil, fmt.Errorf("get_Size: 0x%08x", hr)
	}

View on GitHub (pinned to 0976794618)

Solutions

  1. Retry the prompt render - the async operation often succeeds on a subsequent attempt.
  2. If the error is 'async timed out', check system load / hung media services (restart audiosrv or reboot).
  3. If 'async failed' or 'async cancelled' recurs, verify Windows media features and update Windows.
  4. Increase smtcAsyncTimeout in smtc_windows.go if timeouts are frequent on slow machines.
Defensive patterns

Strategy: retry

Validate before calling

// Cannot pre-validate an async op; instead guard on Windows + retry hint
if runtime.GOOS != "windows" { skipMediaSegment() }

Try / catch

info, err := env.QueryMediaPlayer(player)
if err != nil && strings.Contains(err.Error(), "await RequestAsync") {
    // timed out / cancelled: retry once, else omit segment
    info, err = env.QueryMediaPlayer(player)
    if err != nil { return templateWithoutMedia }
}

Prevention

When it happens

Trigger: awaitAsync observes asyncStatusCanceled, asyncStatusError, or the polling deadline expires while waiting for RequestAsync to complete.

Common situations: System under heavy load so the SMTC async op doesn't complete within the timeout; a hung audio/media service; the operation being canceled by the OS during shutdown or session changes.

Related errors


AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31). Data as JSON: /api/errors/c79b13ba36139208. Report an issue: GitHub.