Skip to content

Bug - ClientApi not initialized on cold start (first login) #33

Description

@LukJanovsky

Summary

On the very first page load after a fresh login (cold start), the TALXIS PCF Grid control intermittently fails to load the web resource specified in ClientApiWebresourceName and does not invoke the function specified in ClientApiFunctionName. The control renders correctly, but all client-side customizations registered via onDatasetControlInitialized (interceptors, event listeners, custom row formatting) are silently skipped. The issue does not reproduce on page refresh or when navigating to the page from another page within the same session. On subsequent cold starts the issue may or may not occur — it is not consistently reproducible.

Steps to Reproduce

  1. Open a private/incognito browser window.
  2. Navigate directly to a model-driven app form that contains a TALXIS PCF Grid subgrid configured
    with ClientApiWebresourceName and ClientApiFunctionName.
  3. Log in when prompted.
  4. Observe the grid — client API customizations may not be applied.
  5. Press F5 to refresh the page.
  6. Observe the grid — client API customizations are now applied correctly.

Note: The issue is intermittent. Repeating steps 1–4 multiple times may occasionally result
in a successful first load. The failure rate appears higher on cold starts with no prior session.

Expected Behavior

Image

ClientApiWebresourceName is loaded and ClientApiFunctionName is invoked on every page load,
including the first cold start after login.

Actual Behavior

Image

On affected cold starts:

  • The web resource (ClientApiWebresourceName) is absent from browser DevTools → Sources.
  • No network request is made for the web resource.
  • ClientApiFunctionName is never called.
  • The following error appears in the browser console:
{
  "errorCode": 2147746581,
  "message": "",
  "raw": "{\"name\":\"UciError\",\"errorCode\":2415919125,\"blockErrorReporting\":false,\"errorAnnotations\":{},\"isAuthError\":false}"
}

Root Cause

Using browser DevTools, the following function was identified in the TALXIS PCF bundle:

async _executeClientApiScript() {
    const e = this.getParameters().ClientApiWebresourceName?.raw
        , t = this.getParameters().ClientApiFunctionName?.raw;
    if (t) {
        try {
            await Xrm.Utility.executeFunction(e, t, [{
                dataset: this.getDataset(),
                controlId: this._options.controlId
            }])
        } catch (e) {
            console.error("Client API web resource execution failed. Client API will not be enabled! Reason: ", e)
        }
    }
}

Based on my investigation, I believe this is caused by a race condition between the PCF control initialization and the UCI framework becoming ready. When _executeClientApiScript is called, Xrm.Utility.executeFunction occasionally throws a UciError (errorCode: 0x8FF00015), which suggests the UCI framework has not yet reached a fully initialized state at that point. The intermittent nature of the failure supports this theory — the call succeeds when the framework happens to be ready in time, and silently fails when it is not. The error is caught and discarded with no retry, leaving the client API permanently disabled for that page load.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions