Select to view content in your preferred language

JavaScript error when using locally hosted ArcGIS Maps SDK CDN in a production Experience Builder application

301
5
3 weeks ago
kendrick123
Emerging Contributor

I am getting the following error when hosting a downloaded ExB app which uses a locally hosted CDN:

index.js:2 Action class widgets/common/table/dist/data-actions/view-in-table load failed. TypeError: Cannot read properties of null (reading 'trim')
at Module.w [as normalize] (init.js:116:221)
at k._sanitizeUrl (IdentityManager.js:35:388)
at k.findOAuthInfo (IdentityManager.js:13:222)
at nI.registerOAuthInfo (index.js:610:23023)
at nI.initToRegisterOAuthForMainPortalAndAGOL (index.js:610:22681)
at nI.<anonymous> (index.js:610:18494)
at Generator.next (<anonymous>)
at s (index.js:610:17219)

I have spent days trying to debug the problem with no success. The error happens if I have a custom widget and also the built in table widget inside the experience. The downloaded experience is hosted on IIS. The error does not happen on the first load but on a random consecutive load and after the error it keeps giving the same error.

Few observations:

  • The error does not surface when using CDN hosted in ESRI servers.
  • The error only happens if experience has a custom widget and the built in table widget.
  • Error disappears when clearing the cache.
  • Error disappears when updating service workers on reload.

So for some reason portalUrl value ends up being undefined and that's what's causing the error inside view-in-table but I have no idea why. I suppose it has something to do with caching and service workers.

As a last resort I did a fresh offline install of ExB developer edition 1.17, downloaded the JSAPI 4.32 and hosted it on IIS. In Experience Builder I created an experience, added the table widget and the sample custom widget that comes with ExB dev edition download and still the same error appears.

I hope that someone can shed some light into why is this happening.

 

0 Kudos
5 Replies
JunshanLiu
Esri Contributor

When the error happens, do you see whether the Maps SDK is loaded?

In your custom widget, do you use the Maps SDK by "import ... from 'esri/..."? If yes, do you add the "jimu-arcgis" dependency in the manifest?

0 Kudos
kendrick123
Emerging Contributor

Hi!

When the error happens I can see that OAuthInfo, IdentityManager and init.js get loaded from the Maps SDK CDN (from the cache).

I even tried with a single custom widget that imported only React and returned an empty div and still the same error happened so it can't be about Maps SDK import in the custom widget.

0 Kudos
JunshanLiu
Esri Contributor

So, a very simple custom widget + table widget + local host JSAPI will trigger the error? We'll check whether we can reproduce this issue.

0 Kudos
ShaozeSun
New Contributor

As you described, I set up the local host JSAPI using JSAPI 4.32 in my local environment, created the app using ExB developer edition 1.17, added the table and sample custom widget. After multiple refreshes and loads, the problem you mentioned was not reproduced. Perhaps you could describe your operations specifically, such as a particular custom widget, or under what conditions you load the app, etc.

0 Kudos
kendrick123
Emerging Contributor

Hi! Thanks for trying it out yourself.

In the webapp with only simple widget and table widget I could produce the error if the page is refreshed before it is fully done loading. With many custom widgets it happens more frequently and also refreshing after everything has fully loaded.

I copied the 'simple widget' webapp and JSAPI to a new cloud server to test whether it is system specific and still I got the same error on a quick refresh. The main workflow I follow is just downloading the app from ExB, unzipping and copying it to IIS wwwroot and doing exactly the same with the JSAPI. Then I load the app via network. Also, the issue is not browser specific.

0 Kudos