angular / angular-cli

CLI tool for Angular
https://cli.angular.dev
MIT License
26.79k stars 11.98k forks source link

Please make timeout configurable in render-worker.ts #29005

Closed e-oz closed 22 hours ago

e-oz commented 1 day ago

Command

build

Description

During pre-rendering, if we need to prerender multiple routes (like 36 routes), pre-rendering fails by timeout. If I manually modify the timeout in this file, it works fine. Yes, it takes time, but it is important to pre-render them all for us.

Describe the solution you'd like

Please add an option to angular.json configuration (or some flag, although an option would be much better - fewer dances with builders).

Describe alternatives you've considered

The only alternative right now is to limit the amount of pre-rendered routes.

alan-agius4 commented 1 day ago

@e-oz, I am curious to why each route is taking more than 30s to render.

We could potentially increase the timeout, however in general 30s should be more than enough to rendering a single route.

e-oz commented 1 day ago

@alan-agius4 it takes a couple of seconds to render 20 routes. my theory: some workers are waiting for the initialization because of the max_threads limit, and if at least one of them fails, all the promises fail (because of Promise.all). This theory comes from practical observations but might be completely wrong.

alan-agius4 commented 1 day ago

The initialization phase is not included in this process.

The 30-second limit applies per route and begins as soon as the route rendering starts. It ends as soon as the route finishes rendering, not when it is added to the queue.

If a timeout occurs, it indicates that one or more routes are taking 30 seconds or longer to render.

e-oz commented 1 day ago

All the pages enlisted in routes.txt send just 2 requests to the server, one takes ~150ms, and another takes ~250ms. There are no heavy requests.

Sometimes pre-rendering fails even with 7 routes to pre-render.

The app is zoneless - can it create a situation when renderer can not detect that the page’s rendering is complete?

alan-agius4 commented 1 day ago

When using zoneless and server rendering, there are certainly some rough edges. However, I would expect the application to stabilize before time rather than the other way.

Could you provide a reproduction of the issue? Does this behavior persist if the application is configured to use zones instead?

e-oz commented 22 hours ago

That’s not a bug report, just a feature request :) Sorry, we decided to move from SSG to full SSR (because SSG doesn’t seem stable enough yet), so I now have no time to research this topic. I’m not sure if I should close this feature request - perhaps someone else will find it and decide to continue researching it. But I don’t mind if you close this issue.

alan-agius4 commented 22 hours ago

SSG is generally stable. I believe a 30-second rendering timeout is typically sufficient. This has been the standard for several major versions, and this is the first time it's been brought to our attention that it's not enough.

If a page doesn't stabilize within 30 seconds, it's usually an indication of a problem within the app itself. In the past, we've seen timeouts with zone.js, often due to the use of timeouts, intervals, or similar mechanisms, which caused delays in stabilizing the page.

Closing for now, please feel free to open a new issue with a reproduction if you manage to find out the root cause. Thanks.