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

Perform additional validation for undefined dependency ranges after readPackage() hook #5517

Open
walkerburgin opened this issue Oct 18, 2022 · 0 comments

Comments

@walkerburgin
Copy link

// This is probably somewhere between a bug and a feature request

pnpm version:

7.13.4, 7.13.5

Code to reproduce the issue:

The simplest repro would be a readPackage() hook that accidentally sets a dependency range to undefined:

function readPackage(pkg) {
  if (pkg.name === "@blueprintjs/core" && pkg.version === "1.40.0") {
      pkg.dependencies["react-addons-css-transition-group"] = undefined;
  }
  return pkg;
}

module.exports = {
  hooks: {
    readPackage,
  },
};

See https://github.com/walkerburgin/pnpm7-readpackage-delete-repro for a standalone repro that's representative of how we actually encountered this while upgrading our large monorepo from pnpm v6 to pnpm v7.

Expected behavior:

In a perfect world, PNPM would either ignores any dependency with an undefined range, or fail with a more explicit error.

Actual behavior:

PNPM crashes with a stack trace like this:

 ERROR  Cannot read properties of undefined (reading 'startsWith')

This error happened while installing the dependencies of @blueprintjs/core@1.40.0

pnpm: Cannot read properties of undefined (reading 'startsWith')
    at resolveDependency (/opt/homebrew/Cellar/pnpm/7.13.4/libexec/dist/pnpm.cjs:134193:74)
    at resolveDependenciesOfDependency (/opt/homebrew/Cellar/pnpm/7.13.4/libexec/dist/pnpm.cjs:133979:45)
    at /opt/homebrew/Cellar/pnpm/7.13.4/libexec/dist/pnpm.cjs:133871:72
    at Array.map (<anonymous>)
    at resolveDependencies (/opt/homebrew/Cellar/pnpm/7.13.4/libexec/dist/pnpm.cjs:133871:45)
    at resolveChildren (/opt/homebrew/Cellar/pnpm/7.13.4/libexec/dist/pnpm.cjs:134046:54)
    at postponedResolution (/opt/homebrew/Cellar/pnpm/7.13.4/libexec/dist/pnpm.cjs:134013:57)
    at /opt/homebrew/Cellar/pnpm/7.13.4/libexec/dist/pnpm.cjs:133808:106
    at Array.map (<anonymous>)
    at /opt/homebrew/Cellar/pnpm/7.13.4/libexec/dist/pnpm.cjs:133808:77

This is maybe tangentially related to #4415 (and to a lesser extent #5493).

Additional information:

  • node -v prints: v16.17.1
  • Windows, macOS, or Linux?: macOS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant