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.

plugin-client-redirects error should return non-zero code on build

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

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

  1. make a docs page
  2. add a duplicate route with plugin-client-redirects plugin
  3. run yarn build
  4. 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/"}
    
  5. however, the return code is still 0 which causes CI to succeed even if there are errors reported:
    $ echo $?
    0
    
    Setting 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:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
matevzcommented, Jun 23, 2022

Thanks guys!

1reaction
Josh-Cenacommented, Jun 16, 2022

So what a good config name could we have for that redirect plugin?

Shall we just reuse it? The idea is basically the same here: trying to output duplicate files at the same location.

should we kill “throw” or “error”?

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.)

Read more comments on GitHub >

github_iconTop 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 >

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