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

[BUG] null not handled by broken npm #6492

Closed
2 tasks done
jelmd opened this issue May 22, 2023 · 3 comments
Closed
2 tasks done

[BUG] null not handled by broken npm #6492

jelmd opened this issue May 22, 2023 · 3 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release

Comments

@jelmd
Copy link

jelmd commented May 22, 2023

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

npm is unusable (unable to npm update) because of un-handled null properties:

npm ERR! Cannot read properties of null (reading 'edgesOut')
...
66 silly fetch manifest styled-components@>= 2
67 silly fetch manifest react@>= 16.8.0
68 silly fetch manifest react-dom@>= 16.8.0
69 silly fetch manifest react-is@>= 16.8.0
70 http fetch GET 200 https://registry.npmjs.org/react-is 11ms (cache stale)
71 timing idealTree Completed in 621ms
72 timing command:update Completed in 627ms
73 verbose stack TypeError: Cannot read properties of null (reading 'edgesOut')
73 verbose stack     at [loadPeerSet] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1307:38)
73 verbose stack     at async [loadPeerSet] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1315:11)
73 verbose stack     at async [buildDepStep] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:929:11)
73 verbose stack     at async Arborist.buildIdealTree (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:207:7)
73 verbose stack     at async Promise.all (index 1)
73 verbose stack     at async Arborist.reify (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:159:5)
73 verbose stack     at async Update.exec (/usr/lib/node_modules/npm/lib/commands/update.js:64:5)
73 verbose stack     at async module.exports (/usr/lib/node_modules/npm/lib/cli.js:134:5)
74 verbose cwd ...

Expected Behavior

npm update should go through w/o any error.

Steps To Reproduce

Try this package.json:

{
    "name": "foobar",
    "description": "Test",
    "repository": "https://github.com/x/y",
    "bugs": {
        "url": "https://github.com/x/y/issues"
    },
    "author": "Foo Bar <foobar@do.main>",
    "contributors": [],
    "version": "0.1.0",
    "private": true,
    "scripts": {
        "db": "NODE_OPTIONS='--no-warnings --loader ts-node/esm' nodemon --watch scripts scripts/db.ts",
        "dev": "next dev",
        "build": "next build",
        "start": "next start",
        "lint": "next lint",
        "clean": "rm -rf .next",
        "realclean": "rm -rf .next node_modules package-lock.json"
    },
    "dependencies": {
        "@next-auth/prisma-adapter": "^1.0.6",
        "@prisma/client": "^4.14.1",
        "next": "13.4.3",
        "nodemailer": "^6.9.2",
        "react": "18.2.0",
        "react-dom": "18.2.0"
    },
    "devDependencies": {
        "@styled-icons/material": "^10.47.0",
        "@styled-icons/fa-solid": "^10.47.0",
        "@types/busboy": "^1.5.0",
        "@types/node": "20.2.3",
        "@types/nodemailer": "^6.4.8",
        "@types/react": "18.2.6",
        "@types/react-dom": "18.2.4",
        "eslint": "8.41.0",
        "eslint-config-next": "13.4.3",
        "prisma": "^4.14.1",
        "typescript": "5.0.4"
    }
}

and run npm i or npm update.

Environment

  • npm:9.5.1
  • Node.js: v18.16.0
  • OS Name: Linux (Ubuntu 20.04)
  • System Model Name: amd64
  • npm config:
prefer-offline = true 
@jelmd jelmd added Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release labels May 22, 2023
@jelmd
Copy link
Author

jelmd commented May 22, 2023

Just in case for reproduction - cleanup the cache, too, e.g. run rm -rf ~/.npm/_cacache/ !

@wraithgar
Copy link
Member

#4787
#5151

@wraithgar wraithgar closed this as not planned Won't fix, can't repro, duplicate, stale May 24, 2023
@jelmd
Copy link
Author

jelmd commented May 24, 2023

BTW: solved the problem with this patch (not sure, whether this is ok, but at least allowed me going back to back work ;-)):

--- /usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js.orig	2023-04-12 05:45:24.000000000 +0200
+++ /usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js	2023-05-24 18:15:49.699840640 +0200
@@ -1304,6 +1304,11 @@
         continue
       }
 
+		var x = node.parent.edgesOut.get(edge.name);
+		//console.log('\nedge.name=\n', edge.name, '\n', x );
+		if (!x)
+			continue;
+	
       const parentEdge = node.parent.edgesOut.get(edge.name)
       const { isProjectRoot, isWorkspace } = node.parent.sourceReference
       const isMine = isProjectRoot || isWorkspace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release
Projects
None yet
Development

No branches or pull requests

2 participants