Angular workspace build runs in local dev environment but not test environment

Discussão em 'Angular' iniciado por James Thackston, Março 5, 2025.

  1. I have an Angular 19 Workspace with a main application and 2 libraries which are built and installed as packages in node_modules. My build is served correctly from my local development environment's IIS server instance but when I deploy to a test server with the same IIS configuration, I get the following browser error when launching the app in Chrome:

    Uncaught TypeError: Cannot read properties of undefined (reading 'browserObject')
    at webcontent.js:1:264
    at webcontent.js:3:152
    at webcontent.js:3:156


    The webcontent.js file is part of a Symantec Endpoint Protection Chrome browser extension. Here is the relevant section of webcontent.js:

    'use strict';
    (function(d) {
    (function() {
    function e(a, b) {
    switch (a) {
    case "SCRIPT":
    return <${a}>function sef() { ${b} }</${a}>;
    case "PHONENUMBER":
    return b.match(/((?!-)\+?(?:[0-9\(\)\/-](?!\/)(?!\n)\s?){7,19}[0-9])(?=\s|\.|;|'|"|\n|$)/g)
    }
    return null
    }
    let c = d.SEFAgent.browserObject.runtime.connect({
    name: "webcontent"
    });
    window.addEventListener("pageshow", a => {
    if (a.persisted) {
    try {
    c.disconnect()
    } catch (b) {
    console.debug(Not able to clean up old port (may not be an issue). Error: ${b})
    }
    c = d.SEFAgent.browserObject.runtime.connect({
    name: "webcontent"
    })
    }
    }

    ... remaining code ...
    }
    }


    On line

    d.SEFAgent.browserObject.runtime.connect()


    'browserObject' is undefined.

    I've checked the configurations in both environments and tested the app using Edge and Chrome. When served from my local IIS instance, it works fine but when I navigate to a test server, it hangs in both Edge and Chrome. I traced the specific problem to the webcontent.js but have been unable to learn why the 'browserObject' is undefined when served from the test environment. I've double checked all relevant environment variables. The test environment deployment is successfully reaching our APIs for the first API call. None of expected subsequent API calls are made. The one successful test environment API call has an abnormally large latency of about 1.5 seconds.

    Why does the application run without errors when served from my local IIS instance but not from a test server with the same configuration?

    Continue reading...

Compartilhe esta Página