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

fix(v2): Don't error if site has no dependencies list #5205

Closed

Conversation

jknoxville
Copy link
Contributor

We noticed that when a site has no dependencies in its package.json, you sometimes get errors when running yarn start.

Oddly, its intermittent, seems to occur the first or second time you run yarn start after a yarn install, but not consistently. We observed it on the flipper website which only has devDependencies, and no dependencies array.

I think it's reasonable that a lot of sites only need devDependencies so this prevents erroring in those cases.

Have you read the [Contributing Guidelines on pull requests]?

Yes

Test Plan

Happy case still succeeds:

cd docusaurus
yarn
cd website
yarn start

I'm unfortunately submitting this fix blind as the issue is intermittent and hard to reproduce.
This is a stack trace from when the problem occurred, which pretty clearly points to where it's happening:

/Users/mweststrate/fbsource/xplat/sonar/website/node_modules/@docusaurus/core/bin/docusaurus.js:50
  const siteDocusaurusPackagesForUpdate = Object.keys(sitePkg.dependencies)
                                                 ^

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at Object.<anonymous> (/Users/mweststrate/fbsource/xplat/sonar/website/node_modules/@docusaurus/core/bin/docusaurus.js:50:50)

Searching the code for dependencies doesn't show any other references except for the migration script which already deals with the undefined case.

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jul 22, 2021
@netlify
Copy link

netlify bot commented Jul 22, 2021

✔️ [V2]
Built without sensitive environment variables

🔨 Explore the source changes: f750e8e

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/60f9464b1fb830000788d5c5

😎 Browse the preview: https://deploy-preview-5205--docusaurus-2.netlify.app

@github-actions
Copy link

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 80
🟢 Accessibility 98
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-5205--docusaurus-2.netlify.app/

@Josh-Cena
Copy link
Collaborator

Er, duplicate of #5204? I think spreading dependencies and also introducing devDependencies looks like a better fix.

@jknoxville
Copy link
Contributor Author

Whoops sorry, closing this one.

@jknoxville jknoxville closed this Jul 22, 2021
@slorber
Copy link
Collaborator

slorber commented Jul 22, 2021

I see thanks, it's the upgrade helper that runs from time to time.

Not sure why your site has no dependency, not even docusaurus packages though? 🤪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants