Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Error handling for prerender #1371

Closed as not planned
Closed as not planned

Description

@vikerman

Bug Report

When there is an error in a prerendered route(like invalid route), just the error stack is printed on the console and there is no good error handling

What modules are related to this issue?

- [ ] aspnetcore-engine
- [X] builders
- [ ] common
- [ ] express-engine
- [ ] hapi-engine
- [ ] module-map-ngfactory-loader

Minimal reproduction with instructions:

ng new univ
cd univ
ng add @nguniversal/express-engine@next
ng run univ:prerender --routes /about (/about is an invalid route)

This produces an error stack in the console and the /about prerender page is still written.

Activity

  1. added this to the 9.0 milestone on Dec 10, 2019
  2. wagnermaciel commented on Jan 21, 2020

    @wagnermaciel
    Contributor

    @vikerman and I discussed this separately but for the sake of documentation:

    There is no good way to determine if an error happened. Angular already implements its own error handler and it is too high up the tree for us to provide our own. We would need to make a change to angular/angular to allow us to pass in our own error handler.

  3. chris13524 commented on Feb 9, 2020

    @chris13524

    @wagnermaciel what's the code here supposed to do, then?

    I also get errors logged to the console but it doesn't tell me from which route it originated from (like the linked code is supposed to).

  4. s2young commented on Mar 3, 2020

    @s2young

    Maybe the issue is actually here. Instead of just rejecting the promise, can that error be stringified and logged? I have no idea what is going wrong in my rendering because all I get is [Error] in the output.

  5. wagnermaciel commented on Mar 5, 2020

    @wagnermaciel
    Contributor

    @chris13524 First - sorry for the delayed response! The code in index.ts happens if we send a message with success: false. This kind of message only gets sent from render.ts when there is an error writing the rendered html to the file system.

    So in summary, the code you pointed out is catching & logging errors that happen when writing the rendered output to the file system. What we want is to catch errors that happen while we are rendering the output, but angular is already catching these errors and there's currently no way for us to detect them.

    @s2young Likewise, the errors you get when rendering would be originating from here. The errors caught here won't be providing you info about what's going wrong in the rendering.

  6. s2young commented on Mar 6, 2020

    @s2young

    Thanks for the response. I guess the bigger issue for me right now is 17021. I can't use prerendering at all until it's actually building output like ng build.

  7. modified the milestones: 9.0, 10.1 on Jun 14, 2020
  8. craheb commented on Sep 16, 2020

    @craheb

    Depending on your scenario, this script may be a hack/workaround for detecting an error.

    #!/usr/bin/env bash
    result=$(ng run univ:prerender --routes /about 2>&1)
    
    if [[ $result == *"ERROR"* ]]; then
        echo "There was an error in prerendering:"
        echo "$result"
        exit 1
    fi
  9. self-assigned this
    on May 22, 2023
  10. alan-agius4 commented on May 22, 2023

    @alan-agius4
    Collaborator
  11. angular-automatic-lock-bot commented on Jun 22, 2023

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  12. locked and limited conversation to collaborators on Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions