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

[DevTools] Manifest version 2 is deprecated #24522

Closed
Tracked by #1012
Bartel-C8 opened this issue May 9, 2022 · 54 comments · Fixed by #25145
Closed
Tracked by #1012

[DevTools] Manifest version 2 is deprecated #24522

Bartel-C8 opened this issue May 9, 2022 · 54 comments · Fixed by #25145

Comments

@Bartel-C8
Copy link

Website or app

https://developer.chrome.com/blog/mv2-transition/

Repro steps

Use latest React DevTools with Electron (Chromium) (18.2.0 / Chromium 100)

  (node:80082) ExtensionLoadWarning: Warnings loading extension at ./node_modules/electron-devtools-vendor/extensions/react-developer-tools:
    Manifest version 2 is deprecated, and support will be removed in 2023. See https://developer.chrome.com/blog/mv2-transition/ for more details.

How often does this bug happen?

Every time

DevTools package (automated)

No response

DevTools version (automated)

No response

Error message (automated)

No response

Error call stack (automated)

No response

Error component stack (automated)

No response

GitHub query string (automated)

No response

@Bartel-C8
Copy link
Author

Redux DevTools issue for reference/inspiration/impact: reduxjs/redux-devtools#1037

@lunaruan lunaruan added Type: Feature Request good first issue and removed Type: Bug Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug labels May 9, 2022
@lunaruan
Copy link
Contributor

lunaruan commented May 9, 2022

Hey! Thanks so much for the heads up! We've added it to our plans for this year. 😊

@DhairyaBahl
Copy link

@lunaruan I would love to work on this issue. Kindly assign this issue to me.

@lunaruan
Copy link
Contributor

lunaruan commented May 9, 2022

Hey, sure you can take a stab at it!

@mondaychen
Copy link
Contributor

@DhairyaBahl that would be nice! When do you plan to start working on it?

@bvaughn
Copy link
Contributor

bvaughn commented May 11, 2022

To my knowledge, the last time we investigated manifest v3 – there were blockers for our adopting it. I think maybe the run_at option was missing the "document_start" maybe but I'm not sure?

@DhairyaBahl
Copy link

@mondaychen I will start exploring this issue soon. Since I am a new contributor to React, successful PR may take some time. If this issue needs to be resolved on urgent basis then do let me know.

@mondaychen
Copy link
Contributor

@bvaughn haven't tested but at least it's still in the V3 docs https://developer.chrome.com/docs/extensions/mv3/content_scripts/#run_time

@mondaychen
Copy link
Contributor

mondaychen commented May 11, 2022

@DhairyaBahl there's a timeline for the migration: https://developer.chrome.com/docs/extensions/mv3/mv2-sunset/
We don't want to wait until last minute... I think for now we hope to get it done by September. That's plenty of time if you are starting now.
You can follow the README under the extension package folder to get started. Let me know if you need help!

@mondaychen mondaychen changed the title [DevTools Bug]: Manifest version 2 is deprecated [DevTools] Manifest version 2 is deprecated May 12, 2022
@JadaMonroe
Copy link

@Hanaffi
Copy link

Hanaffi commented Jun 1, 2022

@lunaruan @gaearon Can you assign this to me please?

@lunaruan
Copy link
Contributor

lunaruan commented Jun 1, 2022

@Hanaffi sure :)

@DhairyaBahl
Copy link

@lunaruan Actually I was working on this issue. 🥲

@lunaruan
Copy link
Contributor

lunaruan commented Jun 1, 2022

@DhairyaBahl Oh no sorry! We thought you weren't because we hadn't heard from you in awhile (sorry people drop out a lot in OSS!). I'll assign this to you instead 😊

Do you know when you'd get around to it, just so we know when to reassign this if needed?

@lunaruan lunaruan assigned DhairyaBahl and unassigned Hanaffi Jun 1, 2022
@DhairyaBahl
Copy link

Do you know when you'd get around to it, just so we know when to reassign this if needed?

Actually @lunaruan I was going through this issue and 've been reading the contributor docs and lots of other docs just to have bit more clarity on this issue coz I am contributing to React for the first time. So, it may take a while before I can make a PR but 'll try to make a PR within a week or two. Hope you understand.

Thanks 🙂

@lunaruan
Copy link
Contributor

lunaruan commented Jun 3, 2022

@DhairyaBahl That works for us! Thanks so much for volunteering to help out!

@DhairyaBahl
Copy link

@lunaruan @mondaychen I am facing problem in building react in Windows. Everything is working perfectly in Linux but even the yarn command is not working on windows and is showing this error.

image

Kindly help me out with this one.

Thanks 🙂

@mondaychen
Copy link
Contributor

@DhairyaBahl are you working on Windows because you no longer have access to your Linux machine? Just wanna make sure because you only need to build it on one OS.
Which yarn command was this?

@AnmolBansalDEV
Copy link

sorry, hanaffi was not active, I submitted the PR. Hope no one is angry as It's my first contribution. @mondaychen

@Hanaffi Hanaffi removed their assignment Aug 6, 2022
@mondaychen
Copy link
Contributor

mondaychen commented Aug 9, 2022

Hi all,
We originally mark this as a "good first issue" as it does not require deep understanding of react or react devtools. So far, we have not seen a mature PR on this issue. As the deadline is fast approaching, we decided we need to get it done soon. If you have something that's almost done, please let me know. Otherwise, please consider this project is taken by a react team member.

@SijaanX
Copy link

SijaanX commented Aug 9, 2022

@mondaychen Hi Mondy,
I agree its a good first issue as I understood everything that needs to be done.

But there is an issue here that im trying to solve which isnt directly related to the manifest upgrade.

Firstly in order to test the changes you need to build the extension locally. Although there is a readme in the package extension rep. , there are still several issues when building the extension locally which I already opened issues for, and 1 got accepted and they changed the readme for, but there arw still more.

If you want I can give you an exact timeline tomorrow as I would like to work on it, but the extension repo is giving me a lot of problems currently.

@mondaychen
Copy link
Contributor

@SijaanX
I agree there's room for improvements in our documentation, and thank you for contributing by creating issues about it.
If you (or anyone else) have more questions regarding how to set up the development environment, build & test the extension, you can ask here or in another issue, and I'd like to offer help.
As for this project, I hope you understand it's actually much more work for team members to guide external contributors to get things done than to get it done ourselves. It's also very unpredictable -- you can see this project was assigned to several different people, and now we are still nowhere near any real progress. For a project with a hard deadline, it's safer for us to assign a teammate to it.

@SijaanX
Copy link

SijaanX commented Aug 9, 2022

@mondaychen I understand you completely and its not a good sign when people just get busy and don't give a notice, and when stuck don't try to get help (which will definitely help a lot of others).
Anyway, I'm building it now locally again, and I will make sure to list all of the issues I face for future contributors.
Again I will completely understand if you give it to a team member, as migration deadline is the start of 2023 which is around the corner.

I will do my best now to try and do the upgrade locally. It would be nice if I succeed anyway :D

@SijaanX
Copy link

SijaanX commented Aug 9, 2022

@mondaychen Issues:

#1: When building the extension locally, you have to run: yarn build-for-devtools from the root repository.

This results in the following:

'cp' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.

I guess the solution to this is to change cp to copy as I'm using windows?

@mondaychen
Copy link
Contributor

@SijaanX if you are having issues with basic bash commands like cp you will encounter the same issue with other commands too. I don’t have a lot of experience developing on Windows, but to my knowledge you probably need to set up a Linux-like command line environment such as WSL https://docs.microsoft.com/en-us/windows/wsl/setup/environment

@SijaanX
Copy link

SijaanX commented Aug 9, 2022

@mondaychen Managed to solve it as I used xcopy with the recursive flags.

@SijaanX
Copy link

SijaanX commented Aug 10, 2022

is this error:

injectGlobalHook.js:2132 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval'". Either the 'unsafe-inline' keyword, a hash ('sha256-jmNafx23y91B5KUD5ahB8ex4/ewYkOS39Bl4Yk3Mweg='), or a nonce ('nonce-...') is required to enable inline execution.

injectCode @ injectGlobalHook.js:2132
page-data.json:1          Failed to load resource: the server responded with a status of 404 ()

related to the fact that I have to change the XMLHttpRequest to fetch() or is it something else?

This is the relevant part from the manifest.json:

  "content_security_policy": {
    "extension_pages": "script-src 'self'; object-src 'self'"
  },

@mondaychen
Copy link
Contributor

Yes, looks like we'll need to either use a different policy or change how we implement injectCode

@AnmolBansalDEV
Copy link

I'm almost done with the updates but I'm not able to test the extension, even though I followed the readme file. any suggestions are highly appreciated. thank you

@mondaychen
Copy link
Contributor

@AnmolBansalDEV Can you describe the issue you are having? Which step did you get stuck with?

@SijaanX
Copy link

SijaanX commented Aug 18, 2022

@mondaychen I managed to change how we inject the code.
Now I'm getting stuck on something else, where I have no idea where to debug it from:

image

Any idea?

@mondaychen
Copy link
Contributor

@SijaanX can you push your code somewhere? I'll take a look

@awells111
Copy link

@SijaanX I have a Windows machine and I have git installed so I use the git bash terminal and I don't have to change any of the commands to build.

mondaychen added a commit that referenced this issue Oct 22, 2022
## Summary

resolves #24522

To upgrade to Manifest V3, one of the biggest issue is that we are no
longer allowed to add a script element with code in textContent so that
it would run synchronously. It's necessary for us because we need to
inject a global hook for react reconciler to detect whether devtools
exist.
To do that, we'll leverage a new API
`chrome.scripting.registerContentScripts` in V3. Particularly, we rely
on the "world" option (added in Chrome v102
[commit](https://chromium.googlesource.com/chromium/src/+/e5ad3451c17b21341b0b9019b074801c44c92c9f))
to run it in the "main world" on the page.

This PR also renames a few content script files so that it's easier to
tell them apart from other extension scripts and understand the purpose
of each of them.

Manifest V3 is not yet ready for Firefox, so we need to keep some code
for compatibility.

## How did you test this change?

`yarn build:chrome && yarn test:chrome`
`yarn build:edge && yarn test:edge`
`yarn build:firefox && yarn test:firefox`
@pomack
Copy link

pomack commented Nov 3, 2022

@mondaychen It's been a couple weeks since the Manifest V3 update was added. What is the timeframe for getting the updated extension into the Chrome webstore?

@mondaychen
Copy link
Contributor

@pomack we've released it to some users within Meta. If nothing goes wrong in the following a few weeks, we will release it to Chrome Web Store

rickhanlonii pushed a commit that referenced this issue Dec 3, 2022
## Summary

resolves #24522

To upgrade to Manifest V3, one of the biggest issue is that we are no
longer allowed to add a script element with code in textContent so that
it would run synchronously. It's necessary for us because we need to
inject a global hook for react reconciler to detect whether devtools
exist.
To do that, we'll leverage a new API
`chrome.scripting.registerContentScripts` in V3. Particularly, we rely
on the "world" option (added in Chrome v102
[commit](https://chromium.googlesource.com/chromium/src/+/e5ad3451c17b21341b0b9019b074801c44c92c9f))
to run it in the "main world" on the page.

This PR also renames a few content script files so that it's easier to
tell them apart from other extension scripts and understand the purpose
of each of them.

Manifest V3 is not yet ready for Firefox, so we need to keep some code
for compatibility.

## How did you test this change?

`yarn build:chrome && yarn test:chrome`
`yarn build:edge && yarn test:edge`
`yarn build:firefox && yarn test:firefox`
@Bartel-C8
Copy link
Author

There are still warnings when using React Devtools with the latest Electron (v22):

┏ Electron -------------------

  (node:50201) ExtensionLoadWarning: Warnings loading extension at /Users/bartel/git/klstr-ctrl/node_modules/electron-devtools-vendor/extensions/react-developer-tools:
    Permission '<all_urls>' is unknown or URL pattern is malformed.
  
  (Use `Electron --trace-warnings ...` to show where the warning was created)

┗ ----------------------------

And:

┏ Electron -------------------

  [50201:1206/093424.883640:ERROR:extensions_browser_client.cc(62)] Extension Error:
    OTR:     false
    Level:   2
    Source:  chrome-extension://dmcmnlnmbgdfljfjniabngbfglcgggdk/build/background.js
    Message: Uncaught TypeError: Cannot read properties of undefined (reading 'registerContentScripts')
    ID:      dmcmnlnmbgdfljfjniabngbfglcgggdk
    Type:    RuntimeError
    Context: chrome-extension://dmcmnlnmbgdfljfjniabngbfglcgggdk/build/background.js
    Stack Trace: 
      {
        Line:     107
        Column:   1
        URL:      chrome-extension://dmcmnlnmbgdfljfjniabngbfglcgggdk/build/background.js
        Function: (anonymous function)
      }

┗ ----------------------------
┏ Electron -------------------

  [50201:1206/093424.884128:ERROR:extensions_browser_client.cc(62)] Extension Error:
    OTR:     false
    Level:   1
    Source:  manifest.json
    Message: Service worker registration failed. Status code: 15
    ID:      dmcmnlnmbgdfljfjniabngbfglcgggdk
    Type:    ManifestError

┗ ----------------------------

Somehow the ID is messed up, I don't know what electron (or my electron install provider) does with this, but it's definitely the React Devtools:

node_modules//electron-devtools-vendor/extensions/react-developer-tools/build/background.js:107: chrome.scripting.registerContentScripts([{

@Bartel-C8
Copy link
Author

Bartel-C8 commented Dec 6, 2022

Apparently, this is a Electron issue (only): electron/electron#36545

But, isn't the "scripting" permission needed for accessing chrome.scripting?
As explained here: https://developer.chrome.com/docs/extensions/reference/scripting/#manifest ?

EDIT: Oh, I see it was changed recently, 4b09b0a, but it's not released like this yet...

@iErik
Copy link

iErik commented Jan 15, 2023

That's still happening for me :c is there any solution or workaround for this issue?

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