1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Show error status when chunk is not loading

Discussão em 'Angular' iniciado por hakuni, Agosto 19, 2025.

  1. hakuni

    hakuni Guest

    Is there any way to see the http error response in a NavigationError?

    When navigating in angular, navigation can fail for different reasons. I'd want to catch at least two of those, namely:

    1. Internet connection is down ("No internet, please try again when connected")
    2. App is updated and the ESBuild-chunks have changed the hashes in file names ("App has been updated, please reload the page")

    Currently, when catching router events,

    this.router.events.subscribe((event) => {
    if (event instanceof NavigationError) {
    console.log(event);
    }
    });


    the event only contains a message "error loading dynamically imported module: [URL to the file]" and some other unhelpful data. I'd want to have the http error response, so I have a reason for the error. Both the above errors result in the same message.

    I've seen people ask similar things here and on Github, but the latest ones I'm able to find are many years old, and someone wrote that Angular doesn't have it's own module loader since a long time, but uses the one of Webpack/ESBuild or whatever you're using. If this is true, things may have changed since the migration to ESBuild. Also, none of those threads led to any proper solutions.

    I'm using Angular 19 and lazy loaded modules with ESBuild.

    Continue reading...

Compartilhe esta Página