{"record":{"id":"f667f0039b31d1c7","repo":"JanDeDobbeleer/oh-my-posh","slug":"async-cancelled","errorCode":null,"errorMessage":"async cancelled","messagePattern":"async cancelled","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/runtime/smtc_windows.go","lineNumber":208,"sourceCode":"\tvar asyncInfo unsafe.Pointer\n\thr := comCall(asyncOp, iunknownQueryInterface,\n\t\tuintptr(unsafe.Pointer(&iidAsyncInfo)),\n\t\tuintptr(unsafe.Pointer(&asyncInfo)),\n\t)\n\tif hr != 0 {\n\t\treturn fmt.Errorf(\"QueryInterface IAsyncInfo: 0x%08x\", hr)\n\t}\n\tdefer comRelease(asyncInfo)\n\n\tdeadline := time.Now().Add(smtcAsyncTimeout)\n\tfor {\n\t\tvar status uint32\n\t\tcomCall(asyncInfo, asyncInfoGetStatus, uintptr(unsafe.Pointer(&status)))\n\t\tswitch status {\n\t\tcase asyncStatusCompleted:\n\t\t\treturn nil\n\t\tcase asyncStatusCanceled:\n\t\t\treturn errors.New(\"async cancelled\")\n\t\tcase asyncStatusError:\n\t\t\treturn errors.New(\"async failed\")\n\t\t}\n\t\tif time.Now().After(deadline) {\n\t\t\treturn errors.New(\"async timed out\")\n\t\t}\n\t\ttime.Sleep(smtcAsyncPollInterval)\n\t}\n}\n\nfunc queryMediaPlayer(player string) (*MediaInfo, error) {\n\t// RoInitialize / RoUninitialize update thread-local state, so we have to\n\t// pin the goroutine to one OS thread for the duration of this call.\n\tgoruntime.LockOSThread()\n\tdefer goruntime.UnlockOSThread()\n\n\t// RO_INIT_MULTITHREADED = 1. S_FALSE (1) means already initialised on\n\t// this thread, which is fine — we still pair with RoUninitialize.","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/runtime/smtc_windows.go#L190-L226","documentation":"awaitAsync polls a WinRT IAsyncInfo operation for the media (SMTC) player query. When the polled status equals asyncStatusCanceled, the underlying WinRT async operation was cancelled before completing, so there is no result to read. This is reported by the OS/COM layer, not by oh-my-posh itself.","triggerScenarios":"queryMediaPlayer or readMediaProperties awaited an async WinRT operation (e.g. GetSessionManagerAsync) whose IAsyncInfo status became asyncStatusCanceled during the polling loop.","commonSituations":"Media session manager torn down mid-operation; system suspending media transport; COM apartment shutdown; another consumer cancelling the operation; rare race on Windows during prompt rendering.","solutions":["Retry the media query on the next prompt render — this is typically transient.","Disable the media playback (spotify/media) segment if the error recurs on your system.","Update oh-my-posh, as SMTC COM polling handling may be improved in newer versions.","Check that no third-party media tool is interfering with the SystemMediaTransportControls session."],"exampleFix":"// before\ninfo, err := readMediaProperties(...) // hard-fails segment\n// after\nif err != nil { return nil, nil } // render segment without media info","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"info, err := readMediaProperties(...)\nif err != nil {\n    // cancelled WinRT op: skip this render, retry next prompt\n    return nil, nil\n}","preventionTips":["Never hard-fail a prompt segment on media query errors.","Re-query each prompt render instead of caching failures.","Update oh-my-posh regularly for SMTC robustness fixes."],"tags":["windows","winrt","media","async"],"backgroundTag":"async-operation-cancelled","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}