java-native-access/jna · error · java.util.concurrent.TimeoutException

No results after <timeout> ms.

Error message

No results after <timeout> ms.

What it means

During WmiQuery's enumerateProperties loop, if the WMI enumerator returns WBEM_S_TIMEDOUT, a TimeoutException is thrown with the elapsed timeout value. The caller waited longer than the configured timeout (ms) for the next WMI result without receiving one.

Source

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

            // Get the data from the query in step 6 -------------------
            Pointer[] pclsObj = new Pointer[1];
            IntByReference uReturn = new IntByReference(0);
            Map<T, WString> wstrMap = new HashMap<>();
            HRESULT hres = null;
            for (T property : propertyEnum.getEnumConstants()) {
                wstrMap.put(property, new WString(property.name()));
            }
            while (enumerator.getPointer() != Pointer.NULL) {
                // Enumerator will be released by calling method so no need to
                // release it here.
                hres = enumerator.Next(timeout, pclsObj.length, pclsObj, uReturn);
                // Enumeration complete or no more data; we're done, exit the loop
                if (hres.intValue() == Wbemcli.WBEM_S_FALSE || hres.intValue() == Wbemcli.WBEM_S_NO_MORE_DATA) {
                    break;
                }
                // Throw exception to notify user of timeout
                if (hres.intValue() == Wbemcli.WBEM_S_TIMEDOUT) {
                    throw new TimeoutException("No results after " + timeout + " ms.");
                }
                // Other exceptions here.
                if (COMUtils.FAILED(hres)) {
                    throw new COMException("Failed to enumerate results.", hres);
                }

                VARIANT.ByReference pVal = new VARIANT.ByReference();
                IntByReference pType = new IntByReference();

                // Get the value of the properties
                IWbemClassObject clsObj = new IWbemClassObject(pclsObj[0]);
                for (T property : propertyEnum.getEnumConstants()) {
                    clsObj.Get(wstrMap.get(property), 0, pVal, pType, null);
                    int vtType = (pVal.getValue() == null ? Variant.VT_NULL : pVal.getVarType()).intValue();
                    int cimType = pType.getValue();
                    switch (vtType) {
                        case Variant.VT_BSTR:
                            values.add(vtType, cimType, property, pVal.stringValue());

View on GitHub (pinned to d036ad9781)

Solutions

  1. Increase the timeout passed to execute(int timeout) to a value realistic for the query.
  2. Optimize the WQL query (select fewer properties, add WHERE clauses) to reduce enumeration time.
  3. Retry the query, since WMI providers are often transiently slow.
  4. Investigate WMI service health (winmgmt service, WMI logs) if timeouts persist.

Example fix

// before
WmiResult<Result> r = query.execute(100); // too short
// after
WmiResult<Result> r = query.execute(30_000);
Defensive patterns

Strategy: retry

Try / catch

try {
    result = query.execute(timeoutMs);
} catch (TimeoutException e) {
    result = retryWithBackoff(query, Math.max(timeoutMs * 2, 30_000));
}

Prevention

When it happens

Trigger: Calling execute(timeout) with a small timeout against a slow or unresponsive WMI provider; queries over remote namespaces with high latency; system under heavy load slowing the WMI service (WinMgmt).

Common situations: Enumerating large classes (Win32_Process with many properties) on loaded machines; remote WMI queries across slow network links; WMI service restarts/hangs; setting timeout to a few ms expecting immediate results.

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/761902ef03a744fd. Report an issue: GitHub.