You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use an up-to-date Archlinux x86_64.
I will try with another distribution....
[EDIT 1]
The same on Ubuntu wily (run with docker + X11 forwarding)
[EDIT 2]
Always with Docker and Ubuntu 12.04, I have the same behaviour...
[EDIT 3]
I have exactly the same behaviour when compiling Electron for Archlinux.
Maybe this bug affect only linux ?
Can someone else try on linux ?
@zcbenz it sounds like you have some insights on what is the cause of this issue. Could you please share them in this thread to help us figure out a workaround?
I confirm indeed the workaround posted above does not work anymore. The call to loadURL has no effect.
Update: by browsing around, I stumbled upon this adaptation of the previous workaround:
app.on("ready",function(){varwin=newBrowserWindow({webPreferences: {nodeIntegration: false,partition: "in-mem",preload: "./preload.js"}});win.loadURL("https://twitter.com/");win.webContents.openDevTools();win.webContents.on('did-get-redirect-request',function(e,oldURL,newURL,isMainFrame,httpResponseCode,requestMethod,refeerrer,header){if(isMainFrame){setTimeout(()=>win.webContents.send('redirect-url',newURL),100);e.preventDefault();}});});// in preload.jsconst{ ipcRenderer }=require('electron');ipcRenderer.on('redirect-url',function(event,url){window.location.assign(url);});
I seem to have found a fix-with-a-catch for the above when it comes to using webviews at least.
Instead of using send() or loadURL(), which both seem not to work after the redirect fail, (even though isCrashed() insists the page is still working), looking through the list of methods I came across executeJavaScript().
(If I use the same methods in the dev tools it works, before and after the re-direct failure).
Other re-directs seem to happen e.g. when you log out so it appears sometimes as though the page loads twice (that's why I lowered the timeout delay to 10ms, although due to page load it is still noticeable to the user). Or loads, and then reloads; I assume this is when Electron allows the re-direct, but the event listener fires for all re-directs.
EDIT:
In addition to the above, I've been playing this morning and it seems that for some strange reason, adding an onbeforeunload event listener, that does not seem to run, allows the re-direct when I want it to (twitter login), but when I was seeing 2 page refreshes when I logged out, I no longer see this, and only get one. It's a hacky fix, but it works.
myWebview.addEventListener("did-get-redirect-request", function (e) {
setTimeout(function() {
myWebview.executeJavaScript(
[
'window.onbeforeunload = function(event){',
'console.log(event);',
'return \'Are you sure you want to leave?\';',
'};',
`window.location = '${e.newURL}';`
].join('');
);
}, 10);
e.preventDefault();
});
Ideally, I would like to have used httpResponseCode, but that doesn't seem available on webviews. @zcbenz would be nice if possible to have a cleaner solution by being able to access this value on webviews. The other parameters mentioned in answers above seem to be available in the event object.
Activity
zcbenz commentedon Nov 18, 2015
Which platform are you using? I'm unable to reproduce on OS X 10.11.
xabufr commentedon Nov 18, 2015
I use an up-to-date Archlinux x86_64.
I will try with another distribution....
[EDIT 1]
The same on Ubuntu wily (run with docker + X11 forwarding)
[EDIT 2]
Always with Docker and Ubuntu 12.04, I have the same behaviour...
[EDIT 3]
I have exactly the same behaviour when compiling Electron for Archlinux.
Maybe this bug affect only linux ?
Can someone else try on linux ?
zcbenz commentedon Dec 10, 2015
I can reproduce the same thing on OS X.
deanchen commentedon Dec 11, 2015
Ran in to the same problem on OSX 10.11.
zcbenz commentedon Jan 29, 2016
Reopened because of #4264.
felicienfrancois commentedon Feb 16, 2016
I get the same issue on windows 10
dogancelik commentedon Feb 23, 2016
If this is about 2FA authentication then yes I have the same issue too.
Windows 8, Electron 0.36.8
felicienfrancois commentedon Feb 24, 2016
@dogancelik it also happen with the simple authentication
sokcuri commentedon Jul 30, 2016
I finally solved this issue. Here's my code.
this code correctly running redirect from main frame
quanglam2807 commentedon Feb 22, 2017
@sokcuri It works!! Thank you so much!
bionut commentedon May 9, 2017
From my testing the workaround above stopped working from electron >=1.6.3, but the issue is not resolved.
alexstrat commentedon May 29, 2017
@zcbenz it sounds like you have some insights on what is the cause of this issue. Could you please share them in this thread to help us figure out a workaround?
I confirm indeed the workaround posted above does not work anymore. The call to
loadURLhas no effect.Update: by browsing around, I stumbled upon this adaptation of the previous workaround:
scoobster17 commentedon Aug 17, 2017
I seem to have found a fix-with-a-catch for the above when it comes to using
webviews at least.Instead of using
send()orloadURL(), which both seem not to work after the redirect fail, (even thoughisCrashed()insists the page is still working), looking through the list of methods I came acrossexecuteJavaScript().(If I use the same methods in the dev tools it works, before and after the re-direct failure).
There is a catch, though.
Other re-directs seem to happen e.g. when you log out so it appears sometimes as though the page loads twice (that's why I lowered the timeout delay to 10ms, although due to page load it is still noticeable to the user). Or loads, and then reloads; I assume this is when Electron allows the re-direct, but the event listener fires for all re-directs.
EDIT:
In addition to the above, I've been playing this morning and it seems that for some strange reason, adding an
onbeforeunloadevent listener, that does not seem to run, allows the re-direct when I want it to (twitter login), but when I was seeing 2 page refreshes when I logged out, I no longer see this, and only get one. It's a hacky fix, but it works.Ideally, I would like to have used
httpResponseCode, but that doesn't seem available on webviews.@zcbenz would be nice if possible to have a cleaner solution by being able to access this value on webviews. The other parameters mentioned in answers above seem to be available in the event object.
Hacky fix for Twitter Login refresh/redirect electron/electron#3471
fix twitter login issues
deepak1556 commentedon Apr 5, 2018
This issue should be fixed with #12535
Syed-Umair commentedon Mar 18, 2019
Hi Team, This issue was fixed in which version of electron release.