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

Substrate Connect Browser Source Map Warnings #1196

Closed
rossbulat opened this issue Aug 10, 2022 · 10 comments · Fixed by #1197
Closed

Substrate Connect Browser Source Map Warnings #1196

rossbulat opened this issue Aug 10, 2022 · 10 comments · Fixed by #1197
Assignees
Labels
bug Something isn't working @substrate/connect

Comments

@rossbulat
Copy link

rossbulat commented Aug 10, 2022

As per @wirednkod, here are some warnings being displayed when running a project with substrate connect.

This may be because of a CRA / webpack 5 issue noted here: https://stackoverflow.com/a/70834076
And being discussed here: facebook/create-react-app#11752

GENERATE_SOURCEMAP=false would remove these warnings, are there any practicalities of having these source maps in production?

WARNING in ./node_modules/@substrate/connect-extension-protocol/dist/mjs/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/macbookpro/polkadot/polkadot-staking-dashboard/node_modules/@substrate/connect-extension-protocol/src/index.ts' file: Error: ENOENT: no such file or directory, open '/Users/macbookpro/polkadot/polkadot-staking-dashboard/node_modules/@substrate/connect-extension-protocol/src/index.ts'
 @ ./node_modules/@substrate/connect/dist/mjs/connector/index.js 3:0-71 22:141-155
 @ ./node_modules/@substrate/connect/dist/mjs/index.js 86:0-37 86:0-37
 @ ./node_modules/@polkadot/rpc-provider/substrate-connect/ScProvider.js 3:0-68 14:46-60 16:0-26 67:78-92
 @ ./node_modules/@polkadot/rpc-provider/substrate-connect/index.js 3:0-32 3:0-32
 @ ./node_modules/@polkadot/rpc-provider/bundle.js 6:0-58 6:0-58
 @ ./node_modules/@polkadot/rpc-provider/index.js 4:0-28 4:0-28
 @ ./node_modules/@polkadot/api/bundle.js 5:0-66 5:0-66 5:0-66
 @ ./node_modules/@polkadot/api/index.js 4:0-28 4:0-28
 @ ./src/contexts/Api/index.tsx 10:0-55 70:21-31 112:26-36
 @ ./src/Providers.tsx 14:0-53 57:6-12 77:20-26 81:39-50
 @ ./src/App.tsx 8:0-38 21:35-44
 @ ./src/index.tsx 8:0-22 16:34-37

WARNING in ./node_modules/@substrate/connect/dist/mjs/WellKnownChain.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/macbookpro/polkadot/polkadot-staking-dashboard/node_modules/@substrate/connect/src/WellKnownChain.ts' file: Error: ENOENT: no such file or directory, open '/Users/macbookpro/polkadot/polkadot-staking-dashboard/node_modules/@substrate/connect/src/WellKnownChain.ts'
 @ ./node_modules/@substrate/connect/dist/mjs/index.js 85:0-53 85:0-53
 @ ./node_modules/@polkadot/rpc-provider/substrate-connect/ScProvider.js 3:0-68 14:46-60 16:0-26 67:78-92
 @ ./node_modules/@polkadot/rpc-provider/substrate-connect/index.js 3:0-32 3:0-32
 @ ./node_modules/@polkadot/rpc-provider/bundle.js 6:0-58 6:0-58
 @ ./node_modules/@polkadot/rpc-provider/index.js 4:0-28 4:0-28
 @ ./node_modules/@polkadot/api/bundle.js 5:0-66 5:0-66 5:0-66
 @ ./node_modules/@polkadot/api/index.js 4:0-28 4:0-28
 @ ./src/contexts/Api/index.tsx 10:0-55 70:21-31 112:26-36
 @ ./src/Providers.tsx 14:0-53 57:6-12 77:20-26 81:39-50
 @ ./src/App.tsx 8:0-38 21:35-44
 @ ./src/index.tsx 8:0-22 16:34-37

WARNING in ./node_modules/@substrate/connect/dist/mjs/connector/extension.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/macbookpro/polkadot/polkadot-staking-dashboard/node_modules/@substrate/connect/src/connector/extension.ts' file: Error: ENOENT: no such file or directory, open '/Users/macbookpro/polkadot/polkadot-staking-dashboard/node_modules/@substrate/connect/src/connector/extension.ts'
 @ ./node_modules/@substrate/connect/dist/mjs/connector/index.js 2:0-69 31:51-68
 @ ./node_modules/@substrate/connect/dist/mjs/index.js 86:0-37 86:0-37
 @ ./node_modules/@polkadot/rpc-provider/substrate-connect/ScProvider.js 3:0-68 14:46-60 16:0-26 67:78-92
 @ ./node_modules/@polkadot/rpc-provider/substrate-connect/index.js 3:0-32 3:0-32
 @ ./node_modules/@polkadot/rpc-provider/bundle.js 6:0-58 6:0-58
 @ ./node_modules/@polkadot/rpc-provider/index.js 4:0-28 4:0-28
 @ ./node_modules/@polkadot/api/bundle.js 5:0-66 5:0-66 5:0-66
 @ ./node_modules/@polkadot/api/index.js 4:0-28 4:0-28
 @ ./src/contexts/Api/index.tsx 10:0-55 70:21-31 112:26-36
 @ ./src/Providers.tsx 14:0-53 57:6-12 77:20-26 81:39-50
 @ ./src/App.tsx 8:0-38 21:35-44
 @ ./src/index.tsx 8:0-22 16:34-37

WARNING in ./node_modules/@substrate/connect/dist/mjs/connector/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/macbookpro/polkadot/polkadot-staking-dashboard/node_modules/@substrate/connect/src/connector/index.ts' file: Error: ENOENT: no such file or directory, open '/Users/macbookpro/polkadot/polkadot-staking-dashboard/node_modules/@substrate/connect/src/connector/index.ts'
 @ ./node_modules/@substrate/connect/dist/mjs/index.js 86:0-37 86:0-37
 @ ./node_modules/@polkadot/rpc-provider/substrate-connect/ScProvider.js 3:0-68 14:46-60 16:0-26 67:78-92
 @ ./node_modules/@polkadot/rpc-provider/substrate-connect/index.js 3:0-32 3:0-32
 @ ./node_modules/@polkadot/rpc-provider/bundle.js 6:0-58 6:0-58
 @ ./node_modules/@polkadot/rpc-provider/index.js 4:0-28 4:0-28
 @ ./node_modules/@polkadot/api/bundle.js 5:0-66 5:0-66 5:0-66
 @ ./node_modules/@polkadot/api/index.js 4:0-28 4:0-28
 @ ./src/contexts/Api/index.tsx 10:0-55 70:21-31 112:26-36
 @ ./src/Providers.tsx 14:0-53 57:6-12 77:20-26 81:39-50
 @ ./src/App.tsx 8:0-38 21:35-44
 @ ./src/index.tsx 8:0-22 16:34-37

WARNING in ./node_modules/@substrate/connect/dist/mjs/connector/smoldot-light.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/macbookpro/polkadot/polkadot-staking-dashboard/node_modules/@substrate/connect/src/connector/smoldot-light.ts' file: Error: ENOENT: no such file or directory, open '/Users/macbookpro/polkadot/polkadot-staking-dashboard/node_modules/@substrate/connect/src/connector/smoldot-light.ts'
 @ ./node_modules/@substrate/connect/dist/mjs/connector/index.js 1:0-71 32:9-24
 @ ./node_modules/@substrate/connect/dist/mjs/index.js 86:0-37 86:0-37
 @ ./node_modules/@polkadot/rpc-provider/substrate-connect/ScProvider.js 3:0-68 14:46-60 16:0-26 67:78-92
 @ ./node_modules/@polkadot/rpc-provider/substrate-connect/index.js 3:0-32 3:0-32
 @ ./node_modules/@polkadot/rpc-provider/bundle.js 6:0-58 6:0-58
 @ ./node_modules/@polkadot/rpc-provider/index.js 4:0-28 4:0-28
 @ ./node_modules/@polkadot/api/bundle.js 5:0-66 5:0-66 5:0-66
 @ ./node_modules/@polkadot/api/index.js 4:0-28 4:0-28
 @ ./src/contexts/Api/index.tsx 10:0-55 70:21-31 112:26-36
 @ ./src/Providers.tsx 14:0-53 57:6-12 77:20-26 81:39-50
 @ ./src/App.tsx 8:0-38 21:35-44
 @ ./src/index.tsx 8:0-22 16:34-37

WARNING in ./node_modules/@substrate/connect/dist/mjs/connector/specs/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/macbookpro/polkadot/polkadot-staking-dashboard/node_modules/@substrate/connect/src/connector/specs/index.ts' file: Error: ENOENT: no such file or directory, open '/Users/macbookpro/polkadot/polkadot-staking-dashboard/node_modules/@substrate/connect/src/connector/specs/index.ts'
 @ ./node_modules/@substrate/connect/dist/mjs/connector/smoldot-light.js 1:0-43 146:25-32
 @ ./node_modules/@substrate/connect/dist/mjs/connector/index.js 1:0-71 32:9-24
 @ ./node_modules/@substrate/connect/dist/mjs/index.js 86:0-37 86:0-37
 @ ./node_modules/@polkadot/rpc-provider/substrate-connect/ScProvider.js 3:0-68 14:46-60 16:0-26 67:78-92
 @ ./node_modules/@polkadot/rpc-provider/substrate-connect/index.js 3:0-32 3:0-32
 @ ./node_modules/@polkadot/rpc-provider/bundle.js 6:0-58 6:0-58
 @ ./node_modules/@polkadot/rpc-provider/index.js 4:0-28 4:0-28
 @ ./node_modules/@polkadot/api/bundle.js 5:0-66 5:0-66 5:0-66
 @ ./node_modules/@polkadot/api/index.js 4:0-28 4:0-28
 @ ./src/contexts/Api/index.tsx 10:0-55 70:21-31 112:26-36
 @ ./src/Providers.tsx 14:0-53 57:6-12 77:20-26 81:39-50
 @ ./src/App.tsx 8:0-38 21:35-44
 @ ./src/index.tsx 8:0-22 16:34-37

WARNING in ./node_modules/@substrate/connect/dist/mjs/connector/types.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/macbookpro/polkadot/polkadot-staking-dashboard/node_modules/@substrate/connect/src/connector/types.ts' file: Error: ENOENT: no such file or directory, open '/Users/macbookpro/polkadot/polkadot-staking-dashboard/node_modules/@substrate/connect/src/connector/types.ts'
 @ ./node_modules/@substrate/connect/dist/mjs/connector/index.js 4:0-27 4:0-27
 @ ./node_modules/@substrate/connect/dist/mjs/index.js 86:0-37 86:0-37
 @ ./node_modules/@polkadot/rpc-provider/substrate-connect/ScProvider.js 3:0-68 14:46-60 16:0-26 67:78-92
 @ ./node_modules/@polkadot/rpc-provider/substrate-connect/index.js 3:0-32 3:0-32
 @ ./node_modules/@polkadot/rpc-provider/bundle.js 6:0-58 6:0-58
 @ ./node_modules/@polkadot/rpc-provider/index.js 4:0-28 4:0-28
 @ ./node_modules/@polkadot/api/bundle.js 5:0-66 5:0-66 5:0-66
 @ ./node_modules/@polkadot/api/index.js 4:0-28 4:0-28
 @ ./src/contexts/Api/index.tsx 10:0-55 70:21-31 112:26-36
 @ ./src/Providers.tsx 14:0-53 57:6-12 77:20-26 81:39-50
 @ ./src/App.tsx 8:0-38 21:35-44
 @ ./src/index.tsx 8:0-22 16:34-37

WARNING in ./node_modules/@substrate/connect/dist/mjs/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/macbookpro/polkadot/polkadot-staking-dashboard/node_modules/@substrate/connect/src/index.ts' file: Error: ENOENT: no such file or directory, open '/Users/macbookpro/polkadot/polkadot-staking-dashboard/node_modules/@substrate/connect/src/index.ts'
 @ ./node_modules/@polkadot/rpc-provider/substrate-connect/ScProvider.js 3:0-68 14:46-60 16:0-26 67:78-92
 @ ./node_modules/@polkadot/rpc-provider/substrate-connect/index.js 3:0-32 3:0-32
 @ ./node_modules/@polkadot/rpc-provider/bundle.js 6:0-58 6:0-58
 @ ./node_modules/@polkadot/rpc-provider/index.js 4:0-28 4:0-28
 @ ./node_modules/@polkadot/api/bundle.js 5:0-66 5:0-66 5:0-66
 @ ./node_modules/@polkadot/api/index.js 4:0-28 4:0-28
 @ ./src/contexts/Api/index.tsx 10:0-55 70:21-31 112:26-36
 @ ./src/Providers.tsx 14:0-53 57:6-12 77:20-26 81:39-50
 @ ./src/App.tsx 8:0-38 21:35-44
 @ ./src/index.tsx 8:0-22 16:34-37

Referencing polkadot-cloud/polkadot-staking-dashboard#166

@wirednkod
Copy link
Contributor

Thank you @rossbulat .This is mentioned as CRA bug, but I think this is a webpack 5 issue.

@wirednkod
Copy link
Contributor

wirednkod commented Aug 10, 2022

This is mentioned as CRA bug, but I think this is a webpack 5 issue.

I have to correct that - the issue appears in the connect and connect-extension-protocol files, which we are building with tsc and not with webpack. After further investigation I realized that the source map files, contain a sources path that leads to non-existent .ts files. I can only end up to not ship bundled code with declarationMap and sourceMap to production but rather inlineSourceMap.

@wirednkod wirednkod self-assigned this Aug 10, 2022
@rossbulat
Copy link
Author

rossbulat commented Aug 10, 2022

Great work discovering the issue! Removing the Source maps is what I'd lean towards purely as an optimisation.

It is also questionable whether devs will want to debug this over assuming we are shipping correct code or just to post an issue if bugs are found.

@wirednkod
Copy link
Contributor

Great work discovering the issue! Removing the Source maps is what I'd lean towards purely as an optimisation.

It is also questionable whether devs will want to debug this over assuming we are shipping correct code or just to post an issue if bugs are found.

I think for now I should leave the inlineSourceMap

@sesh92
Copy link

sesh92 commented Sep 26, 2022

@wirednkod @rossbulat @tomaka
It didn't work, you just move the separated source map file to inline with base64 format, but the issue was about the lack of source files, maybe you wanted to use this?

@wirednkod
Copy link
Contributor

@wirednkod @rossbulat @tomaka It didn't work, you just move the separated source map file to inline with base64 format, but the issue was about the lack of source files, maybe you wanted to use this?

Thank you @sesh92 . Can you please help me understand why this did not work? I am running the deployed and local versions of polkadot dashboard and I do not receive the warnings mentioned in the description.

@sesh92
Copy link

sesh92 commented Sep 26, 2022

@wirednkod I've built a local project with the latest @polkadot/api which includes @polkadot/rpc-provider which includes this fix.

"@polkadot/rpc-provider@npm:9.4.2":
  version: 9.4.2
  resolution: "@polkadot/rpc-provider@npm:9.4.2"
  dependencies:
    "@babel/runtime": ^7.19.0
    "@polkadot/keyring": ^10.1.9
    "@polkadot/types": 9.4.2
    "@polkadot/types-support": 9.4.2
    "@polkadot/util": ^10.1.9
    "@polkadot/util-crypto": ^10.1.9
    "@polkadot/x-fetch": ^10.1.9
    "@polkadot/x-global": ^10.1.9
    "@polkadot/x-ws": ^10.1.9
    "@substrate/connect": 0.7.14
    eventemitter3: ^4.0.7
    mock-socket: ^9.1.5
    nock: ^13.2.9
  checksum: ce4e139b6eda5ff4a1a43d85d36f3def77e8abf5b7c7f11d23a73d0134f4cf7ff06632fe139a102c413348258956cc73810436970762e7ca926471746b9351c1
  languageName: node
  linkType: hard

while build the project I've got the warnings

@wirednkod
Copy link
Contributor

Can you please create a repo with that code for further investigation? I mean the issue for us was that the separated source map files were not discoverable by the build, and making them inline seemed to solve the issue.

I have also a test repo with minimum polkadot/api polkadot/rpc-provider installed and I cannot see those warnings you refer to:

"dependencies": {
    "@polkadot/api": "^9.4.2",
    "@polkadot/rpc-provider": "^9.4.2"
  }

image

@sesh92
Copy link

sesh92 commented Sep 27, 2022

@sesh92
Copy link

sesh92 commented Sep 27, 2022

WARNING in ./node_modules/@substrate/connect-extension-protocol/dist/mjs/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/sesh92/Projects/test/warnings/node_modules/@substrate/connect-extension-protocol/src/index.ts' file: Error: ENOENT: no such file or directory, open '/Users/sesh92/Projects/test/warnings/node_modules/@substrate/connect-extension-protocol/src/index.ts'

WARNING in ./node_modules/@substrate/connect/dist/mjs/WellKnownChain.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/sesh92/Projects/test/warnings/node_modules/@substrate/connect/src/WellKnownChain.ts' file: Error: ENOENT: no such file or directory, open '/Users/sesh92/Projects/test/warnings/node_modules/@substrate/connect/src/WellKnownChain.ts'

WARNING in ./node_modules/@substrate/connect/dist/mjs/connector/extension.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/sesh92/Projects/test/warnings/node_modules/@substrate/connect/src/connector/extension.ts' file: Error: ENOENT: no such file or directory, open '/Users/sesh92/Projects/test/warnings/node_modules/@substrate/connect/src/connector/extension.ts'

WARNING in ./node_modules/@substrate/connect/dist/mjs/connector/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/sesh92/Projects/test/warnings/node_modules/@substrate/connect/src/connector/index.ts' file: Error: ENOENT: no such file or directory, open '/Users/sesh92/Projects/test/warnings/node_modules/@substrate/connect/src/connector/index.ts'

WARNING in ./node_modules/@substrate/connect/dist/mjs/connector/smoldot-light.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/sesh92/Projects/test/warnings/node_modules/@substrate/connect/src/connector/smoldot-light.ts' file: Error: ENOENT: no such file or directory, open '/Users/sesh92/Projects/test/warnings/node_modules/@substrate/connect/src/connector/smoldot-light.ts'

WARNING in ./node_modules/@substrate/connect/dist/mjs/connector/specs/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/sesh92/Projects/test/warnings/node_modules/@substrate/connect/src/connector/specs/index.ts' file: Error: ENOENT: no such file or directory, open '/Users/sesh92/Projects/test/warnings/node_modules/@substrate/connect/src/connector/specs/index.ts'

WARNING in ./node_modules/@substrate/connect/dist/mjs/connector/types.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/sesh92/Projects/test/warnings/node_modules/@substrate/connect/src/connector/types.ts' file: Error: ENOENT: no such file or directory, open '/Users/sesh92/Projects/test/warnings/node_modules/@substrate/connect/src/connector/types.ts'

WARNING in ./node_modules/@substrate/connect/dist/mjs/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/sesh92/Projects/test/warnings/node_modules/@substrate/connect/src/index.ts' file: Error: ENOENT: no such file or directory, open '/Users/sesh92/Projects/test/warnings/node_modules/@substrate/connect/src/index.ts'

webpack compiled with 8 warnings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working @substrate/connect
Projects
None yet
3 participants