Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: don't log more than 100 pages per route #11444

Closed
wants to merge 4 commits into from
Closed

Conversation

ascorbic
Copy link
Contributor

Changes

Currently we log every page generated, which is fine in most cases, but for very large sites is useless, makes the logs hard to use and can affect performance. This PR caps this to 100 pages per route, after which it displays a summary instead.

Testing

Most easily tested with the benchmark scripts.

Docs

Copy link

changeset-bot bot commented Jul 10, 2024

🦋 Changeset detected

Latest commit: 6110473

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Jul 10, 2024
@@ -223,6 +223,9 @@ async function generatePage(
styles,
mod: pageModule,
};

const maxPathsToLog = 100;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to disable this when verbose mode is enabled. I'm not 100% sure how you get it from here, but a search for verbose should hopefully find an example

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Member

@florian-lefebvre florian-lefebvre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk, I found it useful when having some weird errors to log on each page and see what slug was failing so not showing them all would make this harder. Maybe a possibility would be to not log more than 100 by default and have an option to have the full log (using --verbose or equivalent). Don't forget the changeset!

@ematipico
Copy link
Member

This is "potentially" a breaking change because it changes a lot the DX for people. It could potentially be for the docs website, and for people that rely on this log for checking the progress of the build. (I do, in the Biome website)

Also, I wouldn't want to use --verbose because that flag literally litters the console, making it difficult to see where the log of the page occurred.

Comment on lines +241 to +242
const shouldTruncate =
pipeline.logger.options.level !== 'debug' && paths.length > maxPathsToLog;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log all pages if when verbose mode is enabled

@ascorbic
Copy link
Contributor Author

@ematipico do you think this shouldn;t be done at all, or that it should be in a major, or that there should be a specific config setting to enable or disable it?

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to the idea that knowing which page failed in a build is important. (In Starlight for example everything is "one route" but our docs has 4k pages so most would be hidden.)

But maybe that can be fixed somehow by always logging the current route when throwing an error? Not entirely sure if that's possible.

Otherwise a flag to disable the log truncation would help people without having to reach for the full --verbose output, which like Ema said, can be a bit overwhelming.

@ascorbic
Copy link
Contributor Author

Sounds like this is a whole can of worms and not really worth the change!

@ematipico
Copy link
Member

I think it's a valuable change, as you said logging can slow down the build and I agree 100%.

I think we should evaluate this change for 5.0, and worth considering a new flag to log all pages.

I know that Fred has strong feelings around logging, so we should make sure to run the suggestion through him

@bholmesdev
Copy link
Contributor

I also agree logs can get very noisy about a certain threshold, but I'd want to see which page failed if possible during a build. If the current page could be bubbled into the error logs, I'd be +1 to this change!

@bluwy
Copy link
Member

bluwy commented Jul 17, 2024

I'd lean on not changing this at all to prevent the risk of possibly not logging the current page if an error occurred. Error handling could be tricky and happen anywhere, so keeping the logging as simple as possible would be safest for me.

@florian-lefebvre florian-lefebvre removed their request for review July 19, 2024 10:36
@Princesseuh
Copy link
Member

Closing since we won't be doing this, I'm sure improvements could be considered outside of this, though.

@Princesseuh Princesseuh closed this Aug 7, 2024
@bluwy bluwy deleted the log-fewer-pages branch October 8, 2024 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants