Skip to content

Conversation

@arlyxiao
Copy link
Contributor

@arlyxiao arlyxiao commented May 2, 2022

Description

Fixed the issue below

node version: v16.13.2

hydrogen-error

Reproduce steps:

  1. Clone the project
  2. Go to the folder: examples/css-modules
  3. yarn install && yarn dev

Additional context


Before submitting the PR, please make sure you do the following:

  • Read the Contributing Guidelines
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123)
  • Update docs in this repository according to your change
  • Run yarn changeset add if this PR cause a version bump based on Keep a Changelog and adheres to Semantic Versioning

@caution-tape-bot
Copy link

👋 It looks like you're updating JavaScript packages that are known
to cause problems when duplicated.

You can deduplicate them with the yarn-deduplicate utility:

npx yarn-deduplicate --packages graphql react react-dom webpack
npx yarn-deduplicate --scopes @shopify @apollo

If running these commands doesn't produce a change in your yarn.lock file,
you didn't have duplications in these packages and can carry on.

A duplicate React version may cause an invalid hook call warning.

React context providers usually use module-scoped globals as their
default context values. Multiple versions of such packages will yield
multiple global instances, resulting in oblique runtime errors.

"dependencies": {
"@shopify/hydrogen": "latest",
"body-parser": "^1.19.1",
"compression": "^1.7.4",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two solutions to fix this:

  1. Upgrade body-parser (1.20.0) can fix it.
  2. Remove it.

The example doesn't use the package. It can be removed.

compression is useless. I think it can be removed too.

@jplhomer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused. The inclusion of these packages as deps should not cause a dev server error. They are not used in the Hydrogen dev server. 🤔 Can you walk me through the reasoning here?

Copy link
Contributor Author

@arlyxiao arlyxiao May 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error is from the file: examples/css-modules/node_modules/@shopify/hydrogen/node_modules/body-parser/node_modules/http-errors/index.js:261:45)
statuses

The statuses object doesn't have message property

Take a look at the commit (6 months ago) in the http-errors.

jshttp/http-errors@8c38486

before-changes

This can explain that why it throws the error. statuses object which is from another dependency package is not the latest with http-errors package.

When upgrade body-parser into the latest(1.20.0). Then all of the dependencies are latest. So the issue disappear. @jplhomer

@arlyxiao arlyxiao changed the title Fix body-parser issue Fix body-parser issue in css-module example May 2, 2022
Copy link
Contributor

@blittle blittle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for finding this!

Instead of removing body-parser, I would rather that we upgrade it to the latest. You are right, the template doesn't currently need it, but it's meant as a starter. The moment someone starts to take advantage of more advanced features, like the <Form> component, it will be necessary.

@arlyxiao arlyxiao changed the title Fix body-parser issue in css-module example Upgrade body-parser in css-module May 4, 2022
@arlyxiao
Copy link
Contributor Author

arlyxiao commented May 4, 2022

@blittle

I did one fresh clone and tried again. That issue didn't happen again.
However I still upgraded that and rebase with the latest.

@jplhomer removed the locked file before.

This PR might be closed.

@blittle
Copy link
Contributor

blittle commented May 4, 2022

It looks like it's no longer a problem. It would still be great to update those dependencies. @jplhomer any reason the yarn lock file was removed?

@jplhomer
Copy link
Contributor

jplhomer commented May 4, 2022

We don't want yarn.lock files in examples, since it pins the version of Hydrogen to older things and makes it hard to npx them to the latest version. It is gitignored, so I'm not sure how it made it in initially: https://github.com/Shopify/hydrogen/blob/main/.gitignore#L133

Copy link
Contributor

@blittle blittle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arlyxiao as long as body-parser is updated here, might as well also update it for the framework and in the default template.

@arlyxiao
Copy link
Contributor Author

arlyxiao commented May 4, 2022

I'm happy with doing that.

Updated. It's not necessary to add changeset? @blittle

Copy link
Contributor

@blittle blittle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @arlyxiao!

@blittle
Copy link
Contributor

blittle commented May 4, 2022

I'm happy with doing that.

Updated. It's not necessary to add changeset? @blittle

Add the changeset and you'll be in the release notes :)

Remove yarn lock because we should not be versioning a lock file for examples.
@blittle blittle merged commit 5446d54 into Shopify:v1.x-2022-07 May 4, 2022
blittle added a commit that referenced this pull request May 4, 2022
* v1.x-2022-07: (95 commits)
  [ci] release v1.x-2022-07 (#1170)
  Try ignoring hello-world to see if it will get bumped
  Don't consider examples part of the workspace (#1202)
  Fix headers on oxygen (#1201)
  Add bot user agents for Seoradar and Adresults, resolves #1199 (#1200)
  Fix changeset
  updates to docker deploy documentation to resolve run issues (#1196)
  Upgrade body-parser (#1162)
  Fix path for deployments
  Adds ability to add more than one cookie per response (#1161)
  Move Demo Store to templates folder (#1132)
  Avoid additional div element (#1191)
  Whoops this should only be patch
  Adds preconnect <link> for CDN (#1160)
  Bump ejs from 3.1.6 to 3.1.7 (#1147)
  Fix scroll restoration when server props are changed (#1152)
  Typo
  Fixes #1165 by making a missing alt tag a console warning (#1167)
  Remove concurrency directive for Oxygen deployments
  Fix hydrogen-ui dev and build issues (#1169)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants