Skip to content

Object prototype may only be an Object or null: undefined #109

Open

Description

@ningji

When migrating my app from react 17 to 18, got this in chrome when starting my app.

Uncaught runtime errors:
×
ERROR
Object prototype may only be an Object or null: undefined
TypeError: Object prototype may only be an Object or null: undefined
at Function.create ()
at Object.inherits (http://localhost:3010/static/js/bundle.js:62529:31)
at ./node_modules/jws/lib/data-stream.js (http://localhost:3010/static/js/bundle.js:66271:6)
at options.factory (http://localhost:3010/static/js/bundle.js:230212:31)
at webpack_require (http://localhost:3010/static/js/bundle.js:229657:33)
at fn (http://localhost:3010/static/js/bundle.js:229869:21)
at ./node_modules/jws/lib/sign-stream.js (http://localhost:3010/static/js/bundle.js:66295:18)
at options.factory (http://localhost:3010/static/js/bundle.js:230212:31)
at webpack_require (http://localhost:3010/static/js/bundle.js:229657:33)
at fn (http://localhost:3010/static/js/bundle.js:229869:21)

There're plenty of changes i made to migrate to react 18, so not very sure which one caused the issue. I'll update more info if i find out more, but this is the most of the package.json (except our internal libs). Any help appreciated.

  "scripts": {
    "start": "chmod +x ./env.sh && ./env.sh && mv env-config.js ./public/ && PORT=3010 react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "CI=true react-app-rewired test --reporters=default --reporters=jest-junit --testResultsProcessor=jest-sonar-reporter",
    "test:watch": "react-app-rewired test",
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "lint-staged": {
    "*.{html,js,json,jsx,md,sass,scss,yaml,yml}": [
      "npx prettier --write ."
    ],
    "*.{js,jsx}": [
      "npx eslint --fix ."
    ]
  },
  "dependencies": {
    "framer-motion": "10.16.2",
    "jsonwebtoken": "9.0.2",
    "moment": "^2.29.4",
    "moment-timezone": "^0.5.43",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-router-dom": "6.15.0",
    "react-scripts": "5.0.1",
    "react-toastify": "8.2.0",
    "sass": "1.66.1",
    "web-vitals": "3.4.0"
  },
  "devDependencies": {
    "@testing-library/jest-dom": "6.1.2",
    "@testing-library/react": "14.0.0",
    "@testing-library/user-event": "14.4.3",
    "buffer": "^6.0.3",
    "husky": "8.0.3",
    "jest-junit": "16.0.0",
    "jest-sonar-reporter": "2.0.0",
    "lint-staged": "14.0.1",
    "prettier": "3.0.3",
    "process": "^0.11.10",
    "react-app-rewired": "^2.2.1",
    "util": "^0.12.5"
  }
}

Activity

  1. ningji commented on Sep 11, 2023

    @ningji
    Author

    yarn 1.22.19
    node 16.16.0
    MacOS Ventura

  2. b-smets commented on Feb 26, 2024

    @b-smets

    Running into the same issue. Is there any update on this or how to mitigate this?

  3. FritjofH commented on Feb 26, 2024

    @FritjofH

    @b-smets I just got this as well after an npm install. Timing-wise it feels as if we have some library which have upgraded it's dependency hitting a dormant bug here?

  4. b-smets commented on Feb 26, 2024

    @b-smets

    I did some more digging and I think this is caused by Vite externalising stream which causes DataStream to become a Proxy with an undefined prototype. Probably it will work when polyfilling stream in the browser.

  5. b-smets commented on Feb 26, 2024

    @b-smets

    Can confirm that running with the https://www.npmjs.com/package/vite-plugin-node-polyfills plugin, the issue no longer occurs. I suppose the same can be done for other bundlers if required.

    This doesn't seem to be an issue with node-jws itself.

  6. FritjofH commented on Feb 26, 2024

    @FritjofH

    Thanks for the hint!

    I'm using webpack 5 through create-react-scripts with react-app-rewired. Adding the stream polyfill did the resolve the issue for me.

  7. dben89x commented on Nov 19, 2024

    @dben89x

    I ran into this issue, and it resolved itself when I removed jsonwebtoken. Not sure yet how to actually fix it, but hopefully that's a hint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions