Skip to content

injectedModule bug: "Cannot assign to read only property 'request' of object '[object Object]'" #2114

@BenAzlay

Description

@BenAzlay

Current Behavior

The dApp crashes. The log output is below.

Expected Behavior

No response

Steps To Reproduce

  1. I am using react-create-app with Craco
  2. Injected is the only module being used
import { init, useConnectWallet } from "@web3-onboard/react";
import injectedModule from '@web3-onboard/injected-wallets';

const apiKey = process.env.REACT_APP_BLOCKNATIVE_KEY;

const injected = injectedModule();

init({
  apiKey,
  wallets: [injected],
  chains: [
    {
      id: 1,
      token: 'ETH',
      label: 'Ethereum Mainnet',
      rpcUrl: CONSTANTS.RPC_URLS[1],
    },
    {
      id: 8453,
      token: 'ETH',
      label: 'Base',
      rpcUrl: CONSTANTS.RPC_URLS[8453],
    }
  ]
});

What package is effected by this issue?

@web3-onboard/injected

Is this a build or a runtime issue?

Runtime

Package Version

2.10.12

Node Version

18.17.1

What browsers are you seeing the problem on?

Chrome

Relevant log output

Cannot assign to read only property 'request' of object '[object Object]'
TypeError: Cannot assign to read only property 'request' of object '[object Object]'
    at createEIP1193Provider (http://localhost:3000/static/js/bundle.js:337890:20)
    at http://localhost:3000/static/js/bundle.js:349171:99
    at checkFor6963Providers (http://localhost:3000/static/js/bundle.js:349178:10)
    at injected (http://localhost:3000/static/js/bundle.js:349186:86)
    at ./src/config/Layout/index.js (http://localhost:3000/static/js/bundle.js:11284:93)
    at options.factory (http://localhost:3000/static/js/bundle.js:370923:31)
    at __webpack_require__ (http://localhost:3000/static/js/bundle.js:370311:33)
    at fn (http://localhost:3000/static/js/bundle.js:370580:21)
    at ./src/config/App.js (http://localhost:3000/static/js/bundle.js:10770:65)
    at options.factory (http://localhost:3000/static/js/bundle.js:370923:31)

Anything else?

This is my craco.config.js:

const webpack = require('webpack')

module.exports = {
  webpack: {
    configure: {
      resolve: {
        fallback: {
          path: require.resolve('path-browserify')
        },
        alias: {
          assert: 'assert',
          buffer: 'buffer',
          crypto: 'crypto-browserify',
          http: 'stream-http',
          https: 'https-browserify',
          os: 'os-browserify/browser',
          process: 'process/browser',
          stream: 'stream-browserify',
          util: 'util'
        }
      },
      experiments: {
        asyncWebAssembly: true
      },
      plugins: [
        new webpack.ProvidePlugin({
          process: 'process/browser',
          Buffer: ['buffer', 'Buffer']
        })
      ]
    }
  }
}

Sanity Check

  • If this is a build issue, I have included my build config. If this is a runtime issue, I have included reproduction steps and/or a Minimal, Reproducible Example.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions