MarshallOfSound / electron-devtools-installer

An easy way to ensure Chrome DevTools extensions into Electron
MIT License
1.13k stars 139 forks source link

REDUX_DEV_TOOLS Failed to fetch extension #215

Open squidjam opened 2 years ago

squidjam commented 2 years ago

electron-devtools-installer is working properly for React Development Tools but not for Redux DevTools.

Given: "electron-devtools-installer": "^3.2.0" "electron": "^9.4.4"

in electron.js: `const { default: installExtension, REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS } = require ( 'electron-devtools-installer' );

app.whenReady ().then ( () => {
    installExtension( REDUX_DEVTOOLS, {forceDownload: true, loadExtensionOptions: { allowFileAccess: true }  } )
        .then( ( name ) => console.log( `Added Extension:  ${ name }` ) )
        .catch( ( err ) => console.error( 'An error occurred "redux_devtools": ', err ) );
    installExtension( REACT_DEVELOPER_TOOLS )
        .then( ( name ) => console.log( `Added Extension:  ${ name }` ) )
        .catch( ( err ) => console.error( 'An error occurred "react_devtools": ', err ) );
} )

`

Output shows:

Failed to fetch extension, trying 3 more times ... Failed to fetch extension, trying 2 more times Failed to fetch extension, trying 1 more times Failed to fetch extension, trying 0 more times An error occurred "redux_devtools": Error: net::ERR_BLOCKED_BY_RESPONSE at SimpleURLLoaderWrapper. (electron/js2c/browser_init.js:93:6395) at SimpleURLLoaderWrapper.emit (events.js:223:5)

Observed behavior: Redux devtools isn't downloaded.

aabuelenin commented 2 years ago

I've the same issue but it affects all extensions not just REDUX_DEVTOOLS.

Here's what I know so far:

So the culprit is CORS. I tried removing the response header by listening to onBeforeSendHeaders, onHeadersReceived and onBeforeRedirect; and modifying requests/responses. But (and this might be a bug in electron) onHeadersReceived doesn't get called for the second request, maybe because it's the result of a redirection?

dialqueza commented 2 years ago

electron-devtools-installer is working properly for React Development Tools but not for Redux DevTools.

Given: "electron-devtools-installer": "^3.2.0" "electron": "^9.4.4"

in electron.js: `const { default: installExtension, REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS } = require ( 'electron-devtools-installer' );

app.whenReady ().then ( () => {
    installExtension( REDUX_DEVTOOLS, {forceDownload: true, loadExtensionOptions: { allowFileAccess: true }  } )
        .then( ( name ) => console.log( `Added Extension:  ${ name }` ) )
        .catch( ( err ) => console.error( 'An error occurred "redux_devtools": ', err ) );
    installExtension( REACT_DEVELOPER_TOOLS )
        .then( ( name ) => console.log( `Added Extension:  ${ name }` ) )
        .catch( ( err ) => console.error( 'An error occurred "react_devtools": ', err ) );
} )

`

Output shows:

Failed to fetch extension, trying 3 more times ... Failed to fetch extension, trying 2 more times Failed to fetch extension, trying 1 more times Failed to fetch extension, trying 0 more times An error occurred "redux_devtools": Error: net::ERR_BLOCKED_BY_RESPONSE at SimpleURLLoaderWrapper. (electron/js2c/browser_init.js:93:6395) at SimpleURLLoaderWrapper.emit (events.js:223:5)

Observed behavior: Redux devtools isn't downloaded.

We're also experiencing this in VueJS Devtools as well. What's the workaround solution for this?

mduclehcm commented 2 years ago

@dialqueza I have created a workaround patch you can try this

"electron-devtools-installer": "git+https://github.com/mduclehcm/electron-devtools-installer#mduclehcm-patch-1",
LegacyOfKain commented 4 weeks ago

For me what works is to duplicate the code by adding the install extension code twice

app.whenReady ().then ( () => { installExtension( REDUX_DEVTOOLS, {forceDownload: true, loadExtensionOptions: { allowFileAccess: true } } ) .then( ( name ) => console.log( Added Extension: ${ name } ) ) .catch( ( err ) => console.error( 'An error occurred "redux_devtools": ', err ) ); installExtension( REACT_DEVELOPER_TOOLS ) .then( ( name ) => console.log( Added Extension: ${ name } ) ) .catch( ( err ) => console.error( 'An error occurred "react_devtools": ', err ) ); .... .... createWindow(); ..... } )

app.whenReady ().then ( () => { installExtension( REDUX_DEVTOOLS, {forceDownload: true, loadExtensionOptions: { allowFileAccess: true } } ) .then( ( name ) => console.log( Added Extension: ${ name } ) ) .catch( ( err ) => console.error( 'An error occurred "redux_devtools": ', err ) ); installExtension( REACT_DEVELOPER_TOOLS ) .then( ( name ) => console.log( Added Extension: ${ name } ) ) .catch( ( err ) => console.error( 'An error occurred "react_devtools": ', err ) ); } )