plugin-client-redirects error should return non-zero code on build
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
When an error in plugin-client-redirects
occurs, it is only printed to std error while yarn build
returns successfully:
https://github.com/facebook/docusaurus/blob/fb3138d72217788f6224e2cebd9402cb2e0aa3ed/packages/docusaurus-plugin-client-redirects/src/collectRedirects.ts#L119
This will cause CI not to fail in case of a duplicate route or other redirection errors.
Reproducible demo
No response
Steps to reproduce
- make a docs page
- add a duplicate route with
plugin-client-redirects
plugin - run
yarn build
- an error like this is printed to std err:
[ERROR] @docusaurus/plugin-client-redirects: some redirects would override existing paths, and will be ignored: - {"from":"/general/rfcs/","to":"/rfcs/"}
- however, the return code is still
0
which causes CI to succeed even if there are errors reported:
Setting$ echo $? 0
onDuplicateRoutes: 'error'
doesn’t help.
Expected behavior
If the error is reported, yarn build
should return a non-zero code. Ideally, onDuplicateRoutes
option should be considered, so if it is set to warning
or less strict, yarn build
still returns 0
.
Actual behavior
yarn build
returns 0
even if errors are reported by plugin-client-redirects
.
Your environment
- Public source code: /
- Public site URL: /
- Docusaurus version used: 2.0.0-beta.21
- Environment name and version: Node.js 14.17
- Operating system and version: Ubuntu 22.04
Self-service
- I’d be willing to fix this bug myself.
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top Results From Across the Web
How to Fix The ERR_TOO_MANY_REDIRECTS Error - Kinsta
In Google Chrome this error will show as ERR_TOO_MANY_REDIRECTS (as seen below) or This webpage has a redirect loop problem.
Read more >plugin-client-redirects | Docusaurus
This plugin will write additional HTML pages to your static site that redirect the user to your existing Docusaurus pages with JavaScript.
Read more >How to Fix Error Too Many Redirects Issue in WordPress
In this article, we'll show you how to easily fix the 'Error too many redirects' issue in WordPress. We will also cover how...
Read more >How to Fix the Too Many Redirects Error Message - Help Center
When redirects happens in a loop, the browser or the webserver will try to break the loop, and return you the error page....
Read more >Too Many Redirects: What This Error Means & How to Fix It
If you no longer see the too many redirects error, start activating each plugin one by one and reloading your website after each...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks guys!
Shall we just reuse it? The idea is basically the same here: trying to output duplicate files at the same location.
IMO killing “error” would be less trouble for the user, because “throw” is in the init template, and I doubt if anyone uses “error” in practice. (Unless they get confused.)