java-native-access/jna · error · com.sun.jna.platform.win32.COM.COMException

Got a WMI timeout when infinite wait was specified. This sho

Error message

Got a WMI timeout when infinite wait was specified. This should never happen.

What it means

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.

Source

Thrown at contrib/platform/src/com/sun/jna/platform/win32/COM/WbemcliUtil.java:158

        /**
         * @param wmiClassName
         *            The classname to set
         */
        public void setWmiClassName(String wmiClassName) {
            this.wmiClassName = wmiClassName;
        }

        /**
         * Query WMI for values, with no timeout.
         *
         * @return a WmiResult object containing the query results, wrapping an
         *         EnumMap
         */
        public WmiResult<T> execute() {
            try {
                return execute(Wbemcli.WBEM_INFINITE);
            } catch (TimeoutException e) {
                throw new COMException("Got a WMI timeout when infinite wait was specified. This should never happen.");
            }
        }

        /**
         * Query WMI for values, with a specified timeout.
         *
         * @param timeout
         *            Number of milliseconds to wait for results before timing
         *            out. If {@link IEnumWbemClassObject#WBEM_INFINITE} (-1),
         *            will always wait for results. If a timeout occurs, throws
         *            a {@link TimeoutException}.
         *
         * @return a WmiResult object containing the query results, wrapping an
         *         EnumMap
         *
         * @throws TimeoutException
         *             if the query times out before completion
         */

View on GitHub (pinned to d036ad9781)

Solutions

  1. Repair the WMI repository (winmgmt /verifyrepository, winmgmt /resetrepository) on the affected machine.
  2. Call execute(int timeout) with a finite timeout to get a normal TimeoutException you can retry on.
  3. Ensure COM is initialized correctly on the calling thread (Ole32.CoInitializeEx) and the query runs on a compatible thread.
  4. Report as a library/OS bug if reproducible, including Windows version.

Example fix

// before
WmiResult<Result> r = query.execute();
// after
WmiResult<Result> r = query.execute(30_000); // finite timeout, retryable
Defensive patterns

Strategy: retry

Try / catch

try {
    WmiResult<R> r = query.execute();
} catch (COMException e) {
    if (e.getMessage().contains("infinite wait")) { /* WMI subsystem broken; repair or use finite timeout */ }
}

Prevention

When it happens

Trigger: 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.

Common situations: Broken WMI repository on the machine; COM apartment/threading issues causing the enumerator to stall; running inside a sandbox that blocks WMI service responses.

Understand the failure class

Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.

Related errors


AI-assisted analysis of java-native-access/jna@d036ad9781 (2026-09-12). Data as JSON: /api/errors/9158d11d82871bc0. Report an issue: GitHub.