{"record":{"id":"9158d11d82871bc0","repo":"java-native-access/jna","slug":"got-a-wmi-timeout-when-infinite-wait-was-specified-this","errorCode":null,"errorMessage":"Got a WMI timeout when infinite wait was specified. This should never happen.","messagePattern":"Got a WMI timeout when infinite wait was specified\\. This should never happen\\.","errorType":"exception","errorClass":"com.sun.jna.platform.win32.COM.COMException","httpStatus":null,"severity":"error","filePath":"contrib/platform/src/com/sun/jna/platform/win32/COM/WbemcliUtil.java","lineNumber":158,"sourceCode":"        /**\n         * @param wmiClassName\n         *            The classname to set\n         */\n        public void setWmiClassName(String wmiClassName) {\n            this.wmiClassName = wmiClassName;\n        }\n\n        /**\n         * Query WMI for values, with no timeout.\n         *\n         * @return a WmiResult object containing the query results, wrapping an\n         *         EnumMap\n         */\n        public WmiResult<T> execute() {\n            try {\n                return execute(Wbemcli.WBEM_INFINITE);\n            } catch (TimeoutException e) {\n                throw new COMException(\"Got a WMI timeout when infinite wait was specified. This should never happen.\");\n            }\n        }\n\n        /**\n         * Query WMI for values, with a specified timeout.\n         *\n         * @param timeout\n         *            Number of milliseconds to wait for results before timing\n         *            out. If {@link IEnumWbemClassObject#WBEM_INFINITE} (-1),\n         *            will always wait for results. If a timeout occurs, throws\n         *            a {@link TimeoutException}.\n         *\n         * @return a WmiResult object containing the query results, wrapping an\n         *         EnumMap\n         *\n         * @throws TimeoutException\n         *             if the query times out before completion\n         */","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/java-native-access/jna/blob/d036ad9781adad4b66693e8fa7098e4ac665e0a3/contrib/platform/src/com/sun/jna/platform/win32/COM/WbemcliUtil.java#L140-L176","documentation":"WbemcliUtil.WmiQuery.execute() calls execute(WBEM_INFINITE), i.e. an infinite timeout, so a TimeoutException is considered impossible. This COMException is a defensive internal-invariant error signalling that the WMI enumerator returned WBEM_S_TIMEDOUT even though no timeout was configured.","triggerScenarios":"WBEM_S_TIMEDOUT surfaced from enumerateProperties despite WBEM_INFINITE — usually indicates a broken WMI/COM subsystem or a corrupted enumerator state rather than user error.","commonSituations":"Broken WMI repository on the machine; COM apartment/threading issues causing the enumerator to stall; running inside a sandbox that blocks WMI service responses.","solutions":["Repair the WMI repository (winmgmt /verifyrepository, winmgmt /resetrepository) on the affected machine.","Call execute(int timeout) with a finite timeout to get a normal TimeoutException you can retry on.","Ensure COM is initialized correctly on the calling thread (Ole32.CoInitializeEx) and the query runs on a compatible thread.","Report as a library/OS bug if reproducible, including Windows version."],"exampleFix":"// before\nWmiResult<Result> r = query.execute();\n// after\nWmiResult<Result> r = query.execute(30_000); // finite timeout, retryable","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    WmiResult<R> r = query.execute();\n} catch (COMException e) {\n    if (e.getMessage().contains(\"infinite wait\")) { /* WMI subsystem broken; repair or use finite timeout */ }\n}","preventionTips":["Use execute(timeout) with a finite timeout in production code","Keep COM initialization consistent on the query thread","Monitor WMI repository health on target machines"],"tags":["windows","wmi","jna","timeout"],"backgroundTag":"request-timeout","analyzedSha":"d036ad9781adad4b66693e8fa7098e4ac665e0a3","analyzedAt":"2026-09-12T06:50:59.239Z","contentChangedAt":"2026-09-12T06:50:59.239Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}