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

Do not do client-side checks in production #6292

Open
2 tasks done
Josh-Cena opened this issue Jan 8, 2022 · 3 comments
Open
2 tasks done

Do not do client-side checks in production #6292

Josh-Cena opened this issue Jan 8, 2022 · 3 comments
Labels
domain: performance Related to bundle size or perf optimization proposal This issue is a proposal, usually non-trivial change

Comments

@Josh-Cena
Copy link
Collaborator

Josh-Cena commented Jan 8, 2022

Have you read the Contributing Guidelines on issues?

Motivation

We shouldn't do too many client-side checks in production. For example, we have a lot of fail-fast checks for Tabs to prevent bad configurations, which are still present in the production build and the error messages bloat up the bundle. In the spirit of bundle size optimization, we should only throw if process.env.NODE_ENV === 'development', and let it display whatever can be displayed in production.

Alternatively, we can have some minified error messages and have an error decoder? I'm actually not sure what solutions there are out there!

Just ran a search in our site's build output:

All occurrences of "Docusaurus error" (standardized prefix of our browser error message)
website/build/assets/js/bbe72c56.d4f8bb07.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/928837dc.6fe20858.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/e4d91833.a136fd20.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/ede3a018.0e55224e.js:Docusaurus error
website/build/assets/js/d441b611.5e4b0a0e.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/26a1f8a5.066dad69.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/6337a9be.11dbac78.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/5785f4e1.18f2d1bc.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/f32d3a40.7b1ba938.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/0c6f07ad.5f111352.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/a6aa9e1f.d29f2c3f.js:Docusaurus error
website/build/assets/js/59b24822.3dc052ea.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/09f49407.f20ff2e5.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/c6b42a3e.d7862ba4.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/526b68c3.77d8e102.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/cfbaa63c.b9af2a9c.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/5484232b.bc3070ec.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/66e1cd24.00f93679.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/18aa00d9.6d3832bf.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/e79f4725.08fd9642.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/be789628.57fb9051.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/ca6c9079.f92c363a.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/65a6045c.9f513bff.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/bd514b3a.191c8cec.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/6a5ec37e.5ab2a9ca.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/0c1ab1b4.bb48758b.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/ba8b3534.4ef50e0d.js:Docusaurus error
website/build/assets/js/24dfbd6f.5056e6a7.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/ccc49370.56d6a4e2.js:Docusaurus error
website/build/assets/js/eef287dc.9ba350ba.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/0a818389.768752a9.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/b033ed07.c46e283b.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/06c6ffc3.bc86ff3f.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/20606240.9fb594f7.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/dc46eee5.f3c28a43.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/aa3a889a.7bc2e94d.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/0b4b0fdb.1185aec9.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/0ccb688f.aa5d67df.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/e3317ae4.2d43f2bd.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/0f644907.6515bf3d.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/26289d8a.d03ff724.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/c3188b1f.391de04a.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/6bb20d8e.5d320e2e.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/d39a354a.d303b4cd.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/81509a04.af32aeec.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/b3119250.3d1a4452.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/03b66c2f.3ab1283a.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/23abe487.0f4a35f2.js:Docusaurus error
website/build/assets/js/52b0cecd.6899b21c.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/ceca9a07.9fb14fde.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/049acf37.12c8e9cf.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/1a67b452.0e0c77e7.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/8d402a47.47645e97.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/5e710efa.79b73da3.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/6875c492.af179d7f.js:Docusaurus error
website/build/assets/js/9a79a1ee.920a41b4.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/fadae6f0.ec6edae0.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/9f01c295.98815f93.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/a4186ac5.48ed252b.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/e9a235b6.87aa3172.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/ff240b2a.3f5a56f1.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/a0b4b123.ea79e73f.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/46db75b4.059d7b5f.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/8c0cf0ad.a6bcf7d7.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/06a32b20.29be1355.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/fe8c2778.8a739daa.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/e6c9b4a6.edabc0b3.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/16ea500c.fe34221b.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/1a20bc57.fd9d180a.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/073b343e.536d59ec.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/85314578.16043799.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/3c03c7ff.5b25241b.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/6865e64c.9e945108.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/c3fa6412.44ac25e1.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/d1f0b424.2062f39d.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/fda5ac6c.247b5695.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/7f89ba6d.77698a8e.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/58da858f.99a13ca8.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/6e6dcf5c.a11e8d26.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/ba91fdad.44b812ac.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/89e751fc.a45414dc.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/1f391b9e.e9e7ff8f.js:Docusaurus error
website/build/assets/js/3b8c55ea.759245a3.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/8020d841.1b696be6.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/96088abe.20bdfcda.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/02b7a95f.b805d675.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/1be78505.bcc592e6.js:Docusaurus error
website/build/assets/js/bd7149c1.93458f01.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/946bd85a.0f5bd525.js:Docusaurus error
website/build/assets/js/17e8a747.efc79eea.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/e3edcfbe.df0431d5.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/d4f94cc3.c7536bee.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/0cea39aa.4281a78a.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/23385af5.0ad511f1.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/9c57cc82.4a9cf9b1.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/bb3a118c.c9f4de4c.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/7fdd8ddf.a32bc069.js:Docusaurus error
website/build/assets/js/d3523a8e.b1a96c17.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/f618aade.47b9b995.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/a7c63798.eef18772.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/628df8c0.4b0d1a5b.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/37eb7851.592d31a2.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/3dc50dc3.88061e71.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/d36febc2.1ba9b98f.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/1c0ca857.6bddc550.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/64dfb3e9.d621f6a4.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/06e36285.1ff58bcf.js:Docusaurus error
website/build/assets/js/f9bc243c.e16b249d.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/0bb02431.d2d026c2.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/900470d4.c94da0d2.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/209ff87f.b471ea20.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/4bf71794.e7aa9683.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/981b1a30.c48d37e0.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/3efe9127.07066bcc.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/cf4dedb9.33ae7334.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/2cf31def.c57f4788.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/a5816f92.a94a7dac.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/53eadcc9.a2b80777.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/34d1ce2d.9b57ce94.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/828be2eb.d26d7876.js:Docusaurus error
Docusaurus error
Docusaurus error
website/build/assets/js/5a27ef0c.ea30595b.js:Docusaurus error
Docusaurus error
Docusaurus error
Docusaurus error

Self-service

  • I'd be willing to do some initial work on this proposal myself.
@Josh-Cena Josh-Cena added the proposal This issue is a proposal, usually non-trivial change label Jan 8, 2022
@slorber
Copy link
Collaborator

slorber commented Jan 12, 2022

I don't understand 😅

@Josh-Cena
Copy link
Collaborator Author

For example, our tabs component does this check:

  if (defaultValue !== null && !values.some((a) => a.value === defaultValue)) {
    throw new Error(
      `Docusaurus error: The <Tabs> has a defaultValue "${defaultValue}" but none of its children has the corresponding value. Available values are: ${values
        .map((a) => a.value)
        .join(
          ', ',
        )}. If you intend to show no default tab, use defaultValue={null} instead.`,
    );
  }

That's a lot of code and an error message that can't be minified at all. Do we need this to be bundled into production JS? Probably not, because we only serve static content. React also has different error messages during prod and dev right? Only "Minified React error: ..." in prod, and things like "invalid hooks call" in dev.

My grep demonstrates that this error message is actually leaked into our production bundle, which technically can never be thrown.

@slorber
Copy link
Collaborator

slorber commented Jan 12, 2022

Oh I see, you mean https://reactjs.org/docs/error-decoder.html/

Definitively planned, but low-priority as it's just an optimization, not sure the impact would be huge

Actually marked this as planned here last week 🤪

https://docusaurus.canny.io/admin/feedback/feature-requests/p/error-messages-integration

@Josh-Cena Josh-Cena added the domain: performance Related to bundle size or perf optimization label Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: performance Related to bundle size or perf optimization proposal This issue is a proposal, usually non-trivial change
Projects
None yet
Development

No branches or pull requests

2 participants