question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Upgrade to DS beta.21 breaks SSR builds with `useDocsVersion` error

See original GitHub issue

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I’m using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

I just tried upgrading Redux Toolkit’s website from beta.7 to beta.21, and I’m seeing a variation on the “can’t find chalk” error that was discussed in #7398:

TypeError: source_default(...).bold is not a function
TypeError: source_default(...).bold is not a function
TypeError: source_default(...).bold is not a function
[ERROR] Unable to build website for locale en.
[ERROR] Error: Failed to compile with errors.
    at D:\Projects\redux\redux-toolkit\node_modules\@docusaurus\core\lib\webpack\utils.js:180:24

fter going into serverEntry.js inside of node_modules, and commenting out every use of chalk in the error handling, and adding an additional console.error('Actual error: ', err) statement, I’m finally getting something meaningful:

[ERROR] Docusaurus server-side rendering could not render static page with path /rtk-query/usage/error-handling.
Actual error:  ReactContextError
    at useDocsVersion (main:9127:99)
    at DocVersionBanner (main:9136:814)
    at zb (main:81525:195)
    at Cb (main:81528:254)
    at W (main:81534:89)
    at Db (main:81537:98)
    at Eb (main:81536:122)
    at W (main:81534:345)
    at Db (main:81537:98)
    at Cb (main:81529:131) {
  message: 'Hook useDocsVersion is called outside the <DocsVersionProvider>. '
}

except that seems to be internal to Docusaurus and I have no idea why that provider doesn’t exist.

so, three problems here:

  • The actual error isn’t being printed at all
  • The chalk usages appear to be broken
  • I’m getting this useDocsVersion error just from upgrading DS

I’m seeing the same build failures both locally and in CI.

FWIW, I was just able to upgrade the Redux core docs from beta.18 to beta.21 with no errors, so maybe it has to do with RTK’s Yarn monorepo?

Reproducible demo

https://github.com/reduxjs/redux-toolkit/pull/2458

Steps to reproduce

  1. Clone the Redux Toolkit repo as of branch https://github.com/reduxjs/redux-toolkit/tree/docs/ds2-21-updates , as shown in https://github.com/reduxjs/redux-toolkit/pull/2458
  2. Run yarn at the root to install
  3. cd website
  4. yarn build

Expected behavior

The build would succeed cleanly, with no errors

Actual behavior

Per the description, and after adding additional logging to node_modules/@docusaurus/core/lib/client/serverEntry.js, the actual error appears to be

[ERROR] Docusaurus server-side rendering could not render static page with path /rtk-query/usage/error-handling.
Actual error:  ReactContextError
    at useDocsVersion (main:9127:99)
    at DocVersionBanner (main:9136:814)
    at zb (main:81525:195)
    at Cb (main:81528:254)
    at W (main:81534:89)
    at Db (main:81537:98)
    at Eb (main:81536:122)
    at W (main:81534:345)
    at Db (main:81537:98)
    at Cb (main:81529:131) {
  message: 'Hook useDocsVersion is called outside the <DocsVersionProvider>. '
}

So, somehow useDocsVersion isn’t finding a provider after the upgrade.

Your environment

Self-service

  • I’d be willing to fix this bug myself.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
slorbercommented, Jul 6, 2022

@pranabdas I can reproduce your problem and it doesn’t seem like there are 2 different versions of @docusaurus/theme-common

This is not related to the current issue, so let’s discuss it in another place.

Looks like the search plugin introduced changes that makes it break on canary Not sure why exactly that fails but will report on the PR there: https://github.com/easyops-cn/docusaurus-search-local/pull/205

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrade to DS beta.21 breaks SSR builds with ... - bytemeta
The chalk usages appear to be broken; I'm getting this useDocsVersion error just from upgrading DS. I'm seeing the same build failures both...
Read more >
2.0.0-beta.21 - Docusaurus
2.0.0-beta.21 · Breaking Change​ · New Feature​ · Bug Fix​ · Polish​ · Documentation​ · Maintenance​ · Committers: 23​.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found