Upgrade to DS beta.21 breaks SSR builds with `useDocsVersion` error
See original GitHub issueHave you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I’m using the latest version of Docusaurus.
- I have tried the
npm run clear
oryarn 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
- 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
- Run
yarn
at the root to install cd website
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
- Public source code: https://github.com/reduxjs/redux-toolkit/tree/docs/ds2-21-updates/website
- Public site URL: https://redux-toolkit.js.org
- Docusaurus version used: 2.0-beta.21
- Environment/OS: Windows 11, Node 1; also GH Actions CI
Self-service
- I’d be willing to fix this bug myself.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (1 by maintainers)
Top GitHub Comments
@pranabdas see https://github.com/facebook/docusaurus/issues/7728
@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