Skip to content

refactor: move PerfLogger from core to @docusaurus/logger#10480

Merged
slorber merged 5 commits intomainfrom
slorber/move-perflogger
Sep 6, 2024
Merged

refactor: move PerfLogger from core to @docusaurus/logger#10480
slorber merged 5 commits intomainfrom
slorber/move-perflogger

Conversation

@slorber
Copy link
Collaborator

@slorber slorber commented Sep 6, 2024

Motivation

This is a useful tool that I'd like to use in other places of Docusaurus and it looks cleaner to expose it as @docusaurus/logger API rather than @docusaurus/core

Test Plan

CI

Test links

https://deploy-preview-10480--docusaurus-2.netlify.app/

@slorber slorber added the pr: maintenance This PR does not produce any behavior differences to end users when upgrading. label Sep 6, 2024
@slorber slorber requested a review from Josh-Cena as a code owner September 6, 2024 07:26
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Sep 6, 2024
): string {
let res = '';
values.forEach((value, idx) => {
const flag = msgs[idx]!.match(/[a-z]+=$/);

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data

This [regular expression](1) that depends on [library input](2) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](3) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](4) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](5) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](6) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](7) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](8) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](9) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](10) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](11) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](12) may run slow on strings with many repetitions of 'a'.
let res = '';
values.forEach((value, idx) => {
const flag = msgs[idx]!.match(/[a-z]+=$/);
res += msgs[idx]!.replace(/[a-z]+=$/, '');

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data

This [regular expression](1) that depends on [library input](2) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](3) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](4) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](5) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](6) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](7) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](8) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](9) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](10) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](11) may run slow on strings with many repetitions of 'a'. This [regular expression](1) that depends on [library input](12) may run slow on strings with many repetitions of 'a'.
@github-actions
Copy link

github-actions bot commented Sep 6, 2024

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO Report
/ 🟠 70 🟢 98 🟢 96 🟢 100 Report
/docs/installation 🟠 59 🟢 97 🟢 100 🟢 100 Report
/docs/category/getting-started 🟠 74 🟢 100 🟢 100 🟠 86 Report
/blog 🟠 63 🟢 96 🟢 100 🟠 86 Report
/blog/preparing-your-site-for-docusaurus-v3 🔴 48 🟢 92 🟢 100 🟢 100 Report
/blog/tags/release 🟠 64 🟢 96 🟢 100 🟠 86 Report
/blog/tags 🟠 75 🟢 100 🟢 100 🟠 86 Report

@netlify
Copy link

netlify bot commented Sep 6, 2024

[V2]

Name Link
🔨 Latest commit 558e486
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/66dac14ab898dd00085322b5
😎 Deploy Preview https://deploy-preview-10480--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions
Copy link

github-actions bot commented Sep 6, 2024

Size Change: +271 B (0%)

Total Size: 11.5 MB

ℹ️ View Unchanged
Filename Size Change
website/.docusaurus/codeTranslations.json 2 B 0 B
website/.docusaurus/docusaurus.config.mjs 27.9 kB 0 B
website/.docusaurus/globalData.json 30.2 kB 0 B
website/.docusaurus/i18n.json 930 B 0 B
website/.docusaurus/registry.js 155 kB 0 B
website/.docusaurus/routes.js 74.3 kB 0 B
website/.docusaurus/routesChunkNames.json 81.7 kB 0 B
website/.docusaurus/site-metadata.json 2.17 kB 0 B
website/build/assets/css/styles.********.css 113 kB 0 B
website/build/assets/js/main.********.js 666 kB 0 B
website/build/blog.html 61.4 kB 0 B
website/build/blog/2017/12/14/introducing-docusaurus.html 74.8 kB -2 B (0%)
website/build/blog/2018/04/30/How-I-Converted-Profilo-To-Docusaurus.html 47.3 kB +11 B (+0.02%)
website/build/blog/2018/09/11/Towards-Docusaurus-2.html 51.7 kB +11 B (+0.02%)
website/build/blog/2018/12/14/Happy-First-Birthday-Slash.html 30.4 kB -2 B (-0.01%)
website/build/blog/2019/12/30/docusaurus-2019-recap.html 39.6 kB -2 B (-0.01%)
website/build/blog/2020/01/07/tribute-to-endi.html 34 kB -2 B (-0.01%)
website/build/blog/2021/01/19/docusaurus-2020-recap.html 48.9 kB -2 B (0%)
website/build/blog/2021/03/09/releasing-docusaurus-i18n.html 45.1 kB -2 B (0%)
website/build/blog/2021/05/12/announcing-docusaurus-two-beta.html 47.5 kB -2 B (0%)
website/build/blog/2021/11/21/algolia-docsearch-migration.html 53 kB +11 B (+0.02%)
website/build/blog/2022/01/24/docusaurus-2021-recap.html 44.5 kB -2 B (0%)
website/build/blog/2022/08/01/announcing-docusaurus-2.0.html 139 kB -2 B (0%)
website/build/blog/2022/09/01/docusaurus-2.1.html 50.9 kB -2 B (0%)
website/build/blog/archive.html 24.7 kB 0 B
website/build/blog/authors.html 46.5 kB 0 B
website/build/blog/authors/j-marcey.html 65 kB 0 B
website/build/blog/authors/josh-cena.html 43 kB 0 B
website/build/blog/authors/lex-111.html 50.2 kB 0 B
website/build/blog/authors/slorber.html 61.5 kB 0 B
website/build/blog/authors/slorber/authors/2.html 65.4 kB 0 B
website/build/blog/authors/slorber/authors/3.html 77.7 kB 0 B
website/build/blog/authors/slorber/authors/4.html 44.7 kB 0 B
website/build/blog/authors/yangshun.html 57.8 kB 0 B
website/build/blog/authors/zpao.html 43.5 kB 0 B
website/build/blog/page/2.html 66 kB 0 B
website/build/blog/page/3.html 71.7 kB 0 B
website/build/blog/page/4.html 64.2 kB 0 B
website/build/blog/page/5.html 41.9 kB 0 B
website/build/blog/preparing-your-site-for-docusaurus-v3.html 138 kB -2 B (0%)
website/build/blog/releases/2.2.html 49.6 kB -1 B (0%)
website/build/blog/releases/2.3.html 60.8 kB -1 B (0%)
website/build/blog/releases/2.4.html 65.3 kB -1 B (0%)
website/build/blog/releases/3.0.html 111 kB +11 B (+0.01%)
website/build/blog/releases/3.1.html 52 kB 0 B
website/build/blog/releases/3.2.html 48.8 kB -1 B (0%)
website/build/blog/releases/3.3.html 55.5 kB -1 B (0%)
website/build/blog/releases/3.4.html 55.8 kB +6 B (+0.01%)
website/build/blog/releases/3.5.html 58.1 kB +9 B (+0.02%)
website/build/blog/tags.html 28.6 kB 0 B
website/build/blog/upgrading-frontend-dependencies-with-confidence-using-visual-regression-testing.html 128 kB -1 B (0%)
website/build/docs.html 49.4 kB +8 B (+0.02%)
website/build/docs/advanced.html 31.1 kB -1 B (0%)
website/build/docs/advanced/architecture.html 30.7 kB +3 B (+0.01%)
website/build/docs/advanced/client.html 76 kB -1 B (0%)
website/build/docs/advanced/plugins.html 58.6 kB -1 B (0%)
website/build/docs/advanced/routing.html 73.9 kB +7 B (+0.01%)
website/build/docs/advanced/ssg.html 81.5 kB -1 B (0%)
website/build/docs/api/docusaurus-config.html 202 kB -1 B (0%)
website/build/docs/api/misc/@docusaurus/eslint-plugin.html 48.3 kB +3 B (+0.01%)
website/build/docs/api/misc/@docusaurus/eslint-plugin/no-html-links.html 38.1 kB -1 B (0%)
website/build/docs/api/misc/@docusaurus/eslint-plugin/no-untranslated-text.html 37 kB -1 B (0%)
website/build/docs/api/misc/@docusaurus/eslint-plugin/prefer-docusaurus-heading.html 38.3 kB +3 B (+0.01%)
website/build/docs/api/misc/@docusaurus/eslint-plugin/string-literal-i18n-messages.html 41.9 kB -1 B (0%)
website/build/docs/api/misc/@docusaurus/logger.html 39.8 kB -1 B (0%)
website/build/docs/api/misc/create-docusaurus.html 34.9 kB -1 B (0%)
website/build/docs/api/plugin-methods.html 67.4 kB +3 B (0%)
website/build/docs/api/plugin-methods/extend-infrastructure.html 63 kB +3 B (0%)
website/build/docs/api/plugin-methods/i18n-lifecycles.html 60.7 kB +3 B (0%)
website/build/docs/api/plugin-methods/lifecycle-apis.html 170 kB -1 B (0%)
website/build/docs/api/plugin-methods/static-methods.html 46.5 kB +3 B (+0.01%)
website/build/docs/api/plugins.html 31.7 kB -1 B (0%)
website/build/docs/api/plugins/@docusaurus/plugin-client-redirects.html 62.6 kB +12 B (+0.02%)
website/build/docs/api/plugins/@docusaurus/plugin-content-blog.html 198 kB +12 B (+0.01%)
website/build/docs/api/plugins/@docusaurus/plugin-content-docs.html 202 kB +8 B (0%)
website/build/docs/api/plugins/@docusaurus/plugin-content-pages.html 78 kB -1 B (0%)
website/build/docs/api/plugins/@docusaurus/plugin-debug.html 50.5 kB -1 B (0%)
website/build/docs/api/plugins/@docusaurus/plugin-google-analytics.html 51.5 kB -1 B (0%)
website/build/docs/api/plugins/@docusaurus/plugin-google-gtag.html 51 kB -5 B (-0.01%)
website/build/docs/api/plugins/@docusaurus/plugin-google-tag-manager.html 49.8 kB -1 B (0%)
website/build/docs/api/plugins/@docusaurus/plugin-ideal-image.html 51.1 kB +3 B (+0.01%)
website/build/docs/api/plugins/@docusaurus/plugin-pwa.html 122 kB +3 B (0%)
website/build/docs/api/plugins/@docusaurus/plugin-sitemap.html 68.5 kB +5 B (+0.01%)
website/build/docs/api/plugins/@docusaurus/plugin-vercel-analytics.html 42.2 kB +11 B (+0.03%)
website/build/docs/api/themes.html 30.4 kB -1 B (0%)
website/build/docs/api/themes/@docusaurus/theme-classic.html 46.4 kB +3 B (+0.01%)
website/build/docs/api/themes/@docusaurus/theme-live-codeblock.html 38.6 kB +3 B (+0.01%)
website/build/docs/api/themes/@docusaurus/theme-mermaid.html 37.5 kB +3 B (+0.01%)
website/build/docs/api/themes/@docusaurus/theme-search-algolia.html 34.7 kB -1 B (0%)
website/build/docs/api/themes/configuration.html 256 kB +6 B (0%)
website/build/docs/blog.html 219 kB +5 B (0%)
website/build/docs/browser-support.html 51 kB -1 B (0%)
website/build/docs/category/getting-started.html 28.3 kB 0 B
website/build/docs/category/guides.html 36.4 kB 0 B
website/build/docs/cli.html 63.8 kB 0 B
website/build/docs/configuration.html 98.5 kB +3 B (0%)
website/build/docs/create-doc.html 65.3 kB +11 B (+0.02%)
website/build/docs/creating-pages.html 59.1 kB 0 B
website/build/docs/deployment.html 211 kB +8 B (0%)
website/build/docs/docs-introduction.html 53.6 kB -1 B (0%)
website/build/docs/docs-multi-instance.html 78.7 kB +3 B (0%)
website/build/docs/docusaurus-core.html 245 kB -1 B (0%)
website/build/docs/guides/whats-next.html 32.8 kB -1 B (0%)
website/build/docs/i18n/crowdin.html 151 kB +11 B (+0.01%)
website/build/docs/i18n/git.html 82.7 kB +3 B (0%)
website/build/docs/i18n/introduction.html 50.8 kB -1 B (0%)
website/build/docs/i18n/tutorial.html 171 kB +12 B (+0.01%)
website/build/docs/installation.html 73 kB +11 B (+0.02%)
website/build/docs/introduction/index.html 280 B 0 B
website/build/docs/markdown-features.html 83.2 kB 0 B
website/build/docs/markdown-features/admonitions.html 119 kB +3 B (0%)
website/build/docs/markdown-features/assets.html 93.5 kB +1 B (0%)
website/build/docs/markdown-features/code-blocks.html 245 kB +3 B (0%)
website/build/docs/markdown-features/diagrams.html 56 kB +13 B (+0.02%)
website/build/docs/markdown-features/head-metadata.html 52.8 kB -1 B (0%)
website/build/docs/markdown-features/links.html 43.1 kB -1 B (0%)
website/build/docs/markdown-features/math-equations.html 95.4 kB +10 B (+0.01%)
website/build/docs/markdown-features/plugins.html 101 kB +7 B (+0.01%)
website/build/docs/markdown-features/react.html 144 kB 0 B
website/build/docs/markdown-features/tabs.html 148 kB -1 B (0%)
website/build/docs/markdown-features/toc.html 88.8 kB +3 B (0%)
website/build/docs/migration.html 43 kB -2 B (0%)
website/build/docs/migration/v2.html 41.3 kB -1 B (0%)
website/build/docs/migration/v2/automated.html 42.6 kB -1 B (0%)
website/build/docs/migration/v2/manual.html 207 kB -1 B (0%)
website/build/docs/migration/v2/translated-sites.html 52.8 kB -1 B (0%)
website/build/docs/migration/v2/versioned-sites.html 67.2 kB -1 B (0%)
website/build/docs/migration/v3.html 218 kB 0 B
website/build/docs/playground.html 32.5 kB -1 B (0%)
website/build/docs/resources/index.html 325 B 0 B
website/build/docs/search.html 121 kB 0 B
website/build/docs/seo.html 93 kB +12 B (+0.01%)
website/build/docs/sidebar.html 136 kB +3 B (0%)
website/build/docs/sidebar/autogenerated.html 156 kB +12 B (+0.01%)
website/build/docs/sidebar/items.html 188 kB -1 B (0%)
website/build/docs/sidebar/multiple-sidebars.html 67.1 kB +3 B (0%)
website/build/docs/static-assets.html 56.3 kB +3 B (+0.01%)
website/build/docs/styling-layout.html 141 kB -1 B (0%)
website/build/docs/support/index.html 319 B 0 B
website/build/docs/swizzling.html 120 kB +13 B (+0.01%)
website/build/docs/team/index.html 310 B 0 B
website/build/docs/typescript-support.html 65.4 kB -1 B (0%)
website/build/docs/using-plugins.html 115 kB +12 B (+0.01%)
website/build/docs/versioning.html 87.1 kB +12 B (+0.01%)
website/build/index.html 37.8 kB 0 B

compressed-size-action

@slorber slorber merged commit 897ebbe into main Sep 6, 2024
@slorber slorber deleted the slorber/move-perflogger branch September 6, 2024 08:58
@marvin-xm
Copy link

Hi, I am trying to upgrade my website to Docusaurus V3, after update to v3.7. The following error occurs

Module not found: Error: Can't resolve 'async_hooks' in '/home/bento/docs-public/node_modules/@docusaurus/logger/lib'

Then I add the config, async_hooks: false. Another similar issue occurs
async_hooks_1.AsyncLocalStorage is not a constructor TypeError: async_hooks_1.AsyncLocalStorage is not a constructor at eval (webpack-internal:///./node_modules/@docusaurus/logger/lib/perfLogger.js:11:20) at ./node_modules/@docusaurus/logger/lib/perfLogger.js (http://localhost:60503/vendors-node_modules_docusaurus_logger_lib_index_js-node_modules_httpsnippet_src_index_js.js:359:1) at __webpack_require__ (http://localhost:60503/runtime~main.js:34:32) at fn (http://localhost:60503/runtime~main.js:334:21) at eval (webpack-internal:///./node_modules/@docusaurus/logger/lib/index.js:10:50) at ./node_modules/@docusaurus/logger/lib/index.js (http://localhost:60503/vendors-node_modules_docusaurus_logger_lib_index_js-node_modules_httpsnippet_src_index_js.js:343:1) at __webpack_require__ (http://localhost:60503/runtime~main.js:34:32) at fn (http://localhost:60503/runtime~main.js:334:21) at eval (webpack-internal:///./src/theme/ApiObjectTable/index.js:9:76) at ./src/theme/ApiObjectTable/index.js (http://localhost:60503/content---connect-api-fulfillment-users-create-user-1-d-0-b7d.js:39:1)

After checking the code, I found this PR has something related to my issue. Currently I do not have a better solution but can only stay at 3.5.2. Do you have other suggestion?

@slorber
Copy link
Collaborator Author

slorber commented Jan 11, 2025

I doubt this PR is the problem, it works fine for many others

It's not possible to help without a repro and your env. It could be a Node.js bug for example

@marvin-xm
Copy link

Thanks for the response.
The following are my dependency. Since I am not clear whether it is node issue or docusaurus issue. Just post my env here.

Node version: 20.11
Yarn: v1.22.22

"dependencies": {
    "@docusaurus/core": "^3.7.0",
    "@docusaurus/plugin-client-redirects": "^3.7.0",
    "@docusaurus/plugin-ideal-image": "^3.7.0",
    "@docusaurus/preset-classic": "^3.7.0",
    "@svgr/webpack": "^8.1.0",
    "algoliasearch": "^5.18.0",
    "algoliasearch-helper": "^3.22.6",
    "buffer": "^6.0.3",
    "clsx": "^2.1.0",
    "glob": "^10.3.3",
    "httpsnippet": "^2.0.0",
    "lodash.ismatch": "^4.4.0",
    "process": "^0.11.10",
    "querystring-es3": "^0.2.1",
    "react": "^18.3.0",
    "react-dom": "^18.3.0",
    "stream-browserify": "^3.0.0",
    "url": "^0.11.0",
    "util": "^0.12.5",
    "webpack": "^5.97.1",
    "xml2js": "^0.6.0"
  },

Currently I fixed the issue by manually add a mock file src/mocks/async_hooks.js, during development.

class AsyncLocalStorage {
    constructor() {
      this.store = new Map();
    }
  
    run(store, callback) {
      return callback();
    }
  
    getStore() {
      return null;
    }
  }
  
  module.exports = {
    AsyncLocalStorage,
  };

In production, I removed the use of logger and above.

@slorber
Copy link
Collaborator Author

slorber commented Jan 16, 2025

Can't help without a repro

If you can't create a repro, then it's likely something special on your site that breaks things

This AsyncLocalStorage feature has been stable in Node for a long time already:

CleanShot 2025-01-16 at 11 27 39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA pr: maintenance This PR does not produce any behavior differences to end users when upgrading.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants