<h3 dir="auto">Preflight Checklist</h3>
<ul dir="auto">
<li>[ I have read the <a href="https://github.com/electron/electron/blob/master/CONTRIBUTING.md">Contributing Guidelines</a> for this project. ]</li>
<li>[ I agree to follow the <a href="https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md">Code of Conduct</a> that this project adheres to. ]</li>
<li>[ I have searched the issue tracker for an issue that matches the one I want to file, without success.]</li>
</ul>
<h3 dir="auto">Issue Details</h3>
<ul dir="auto">
<li><strong>Electron Version:</strong>
<ul dir="auto">
<li>Electron  v11.0.4</li>
</ul>
</li>
<li><strong>Operating System:</strong>
<ul dir="auto">
<li>Windows 10</li>
</ul>
</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">I am using net.request. usually net.request will return set-cookie in the response only in 200 response. In case of redirect response like 301, 304, the set-cookie header will not be returned even though it exists on the header. It should be returned.</p>
<h3 dir="auto">Actual Behavior</h3>
<p dir="auto">set-cookie response header is not coming in the response</p>
<p dir="auto">Please check this link. Already someone asked the same issue..<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="628014135" data-permission-text="Title is private" data-url="https://github.com/electron/electron/issues/23865" data-hovercard-type="issue" data-hovercard-url="/electron/electron/issues/23865/hovercard" href="https://github.com/electron/electron/issues/23865">#23865</a></p>
<ul dir="auto">
<li><strong>Electron Version:</strong><br>
-4.0.4</li>
<li><strong>Operating System:</strong><br>
-Window 10</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">I'm checking for update in every 3 hours. So If update is available I'll create a dialog.showMessageBox popup and it will notify the user that update is available do you want to download. Again in next 3 hours the popup will appear but this time 2 popups will appear and in next 3 hour 3 and so on.</p>
<h3 dir="auto">Actual Behavior</h3>
<p dir="auto">When popup is hide it should removed from  the memory.</p>
<h3 dir="auto">To Reproduce</h3>



<h3 dir="auto">Screenshots</h3>

<h3 dir="auto">Additional Information</h3>
<p dir="auto">main.js</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const {app, BrowserWindow, dialog, ipcMain} = require('electron'); // Load electron and import it's modules
const {autoUpdater} = require('electron-updater'); // electron updater to update the application on run-time.
const log = require('electron-log');
const downloadProgressBar = require('electron-progressbar'); // progressbar to show update downloading process.
console.dir(dialog.showMessageBox)
const appData = require('./config.js');

let CONFIG_DATA = appData.module;
const server = 'http://localhost:8080';

let isPageLoaded = false;
let updateAvailabelPopup = null;
let errorPopup = null;
let progressWindow = null;
let installUpdatePopup = null;

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win;
let downloadProgress = 0;
autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = 'info';

autoUpdater.autoDownload = CONFIG_DATA.updateAutoDownload; // update auto download is false.
autoUpdater.autoInstallOnAppQuit = CONFIG_DATA.autoInstallOnAppQuit; // app install on quit automatically is false.
//autoUpdater.channel = 'latest';

process.env.NODE_ENV = CONFIG_DATA.developmentMode; // set mode to production.



function createWindow () {
    // Create the browser window.
	
    win = new BrowserWindow({width: CONFIG_DATA.windowWidth, height: CONFIG_DATA.windowHeight, fullscreen: CONFIG_DATA.isFullScreenScreen});

    win.setMenu(null);
	
	// Open the DevTools.
    win.webContents.openDevTools();
	
	
    // Emitted when the window is closed.
    win.on('closed', () =&gt; {
        // Dereference the window object, usually you would store windows
        // in an array if your app supports multi windows, this is the time
        // when you should delete the corresponding element.
        win = null;
    });
}



// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', () =&gt; {
	autoUpdater.setFeedURL(server); 
	autoUpdater.checkForUpdates(); // Initiate the checking for latest update.
	
	setInterval(() =&gt; {
		autoUpdater.checkForUpdates();
	}, 1000 * 60 * 3);
	
	createWindow(); // Create the game window.
});

// Quit when all windows are closed.
app.on('window-all-closed', () =&gt; {
    // On macOS it is common for applications and their menu bar
    // to stay active until the user quits explicitly with Cmd + Q
    if (process.platform !== 'darwin') {
		app.quit();
}
});

app.on('activate', () =&gt; {
    // On macOS it's common to re-create a window in the app when the
    // dock icon is clicked and there are no other windows open.
    if (win === null) {
		createWindow();
}
});

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.

app.on(&quot;test&quot;,(arg) =&gt; {
    win.webContents.print({silent: false});
});

// check if update is availabel.

autoUpdater.on('checking-for-update', () =&gt; {
			// If update is availabel download it now or later.
			console.log('checking for update......!!!!!!')
			autoUpdater.on('update-available', (ev,info) =&gt; {
			updateAvailabelPopup = dialog.showMessageBox({
					type: 'info',
					title: 'Update Availabel',
					messgae: 'A new Update availabel. Please update now.',
					buttons: ['Update', 'No'],
					cancelId: 1
				}, (index, val) =&gt; {
					if(index === 1){
						// if user cancel update load the game.
						if(!isPageLoaded)
							loadPage();
						return;
					}else{
							// If update have any error.
							autoUpdater.on('error', (ev, err) =&gt; {
								win.quit();
							 errorPopup = dialog.showMessageBox({
									type: 'info',
									title: 'Error',
									message: 'Error...',
									detail: err,
									cancelId: 1
								});
							});
						// Download the update.
						autoUpdater.downloadUpdate();	
						
						//if( process.platform !== 'win32'){
							progressWindow = new downloadProgressBar({
								title: 'Downloading Update...',
								text: 'Downloading Update. Please Wait...',
								detail: 'Wait...',
								indeterminate: CONFIG_DATA.progressType				
							})
							
							autoUpdater.on('download-progress', ({percent}) =&gt; {
								console.log('download progress')
								progressWindow.value = percent;	
								downloadProgress = percent;
							});
							
							progressWindow.on('progress', (value) =&gt; {
								progressWindow.detail = downloadProgress.toFixed(1);		
							})
							
							.on('aborted', function() {
								if(win)	win.quit();
							});
						//}

						// Update is downloaded.
						autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) =&gt; {
							 progressWindow.setCompleted();
							 console.log('update downloaded')
							const dialogOptns = {
								type: 'info',
								title: 'Update Ready..!!',
								message: process.platform === 'win32' ? releaseNotes : releaseName,
								buttons: ['Yes', 'Later']	,
								cancelId: 1								
							}
							
							installUpdatePopup = dialog.showMessageBox(dialogOptns, (response) =&gt; {
								if(response === 0) autoUpdater.quitAndInstall();
								else if(!isPageLoaded) loadPage();
								
							})			
						})
					}			
				})
			});
			
		
			// Load the game if update is not availabel.
			autoUpdater.on('update-not-available', (ev,info) =&gt; {
				// and load the index.html of the app.
				if(!isPageLoaded){
					loadPage();
				}
			});		
			if(isPageLoaded){
				win.reload()
			}
});

function loadPage(ref){
	isPageLoaded = true;
	win.loadFile('app/index.html');
}

function cleanUp(popupArray){
	console.log(popupArray)
	for(let popup of popupArray){
		if(popup !== null &amp;&amp; popup !== undefined){
			popup.destroy();
		}
	}
}"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-kos">{</span>app<span class="pl-kos">,</span> BrowserWindow<span class="pl-kos">,</span> dialog<span class="pl-kos">,</span> ipcMain<span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'electron'</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// Load electron and import it's modules</span>
<span class="pl-k">const</span> <span class="pl-kos">{</span>autoUpdater<span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'electron-updater'</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// electron updater to update the application on run-time.</span>
<span class="pl-k">const</span> <span class="pl-s1">log</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'electron-log'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-s1">downloadProgressBar</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'electron-progressbar'</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// progressbar to show update downloading process.</span>
<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">dir</span><span class="pl-kos">(</span><span class="pl-s1">dialog</span><span class="pl-kos">.</span><span class="pl-c1">showMessageBox</span><span class="pl-kos">)</span>
<span class="pl-k">const</span> <span class="pl-s1">appData</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'./config.js'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">let</span> <span class="pl-c1">CONFIG_DATA</span> <span class="pl-c1">=</span> <span class="pl-s1">appData</span><span class="pl-kos">.</span><span class="pl-c1">module</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-s1">server</span> <span class="pl-c1">=</span> <span class="pl-s">'http://localhost:8080'</span><span class="pl-kos">;</span>

<span class="pl-k">let</span> <span class="pl-s1">isPageLoaded</span> <span class="pl-c1">=</span> <span class="pl-c1">false</span><span class="pl-kos">;</span>
<span class="pl-k">let</span> <span class="pl-s1">updateAvailabelPopup</span> <span class="pl-c1">=</span> <span class="pl-c1">null</span><span class="pl-kos">;</span>
<span class="pl-k">let</span> <span class="pl-s1">errorPopup</span> <span class="pl-c1">=</span> <span class="pl-c1">null</span><span class="pl-kos">;</span>
<span class="pl-k">let</span> <span class="pl-s1">progressWindow</span> <span class="pl-c1">=</span> <span class="pl-c1">null</span><span class="pl-kos">;</span>
<span class="pl-k">let</span> <span class="pl-s1">installUpdatePopup</span> <span class="pl-c1">=</span> <span class="pl-c1">null</span><span class="pl-kos">;</span>

<span class="pl-c">// Keep a global reference of the window object, if you don't, the window will</span>
<span class="pl-c">// be closed automatically when the JavaScript object is garbage collected.</span>
<span class="pl-k">let</span> <span class="pl-s1">win</span><span class="pl-kos">;</span>
<span class="pl-k">let</span> <span class="pl-s1">downloadProgress</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">;</span>
<span class="pl-s1">autoUpdater</span><span class="pl-kos">.</span><span class="pl-c1">logger</span> <span class="pl-c1">=</span> <span class="pl-s1">log</span><span class="pl-kos">;</span>
<span class="pl-s1">autoUpdater</span><span class="pl-kos">.</span><span class="pl-c1">logger</span><span class="pl-kos">.</span><span class="pl-c1">transports</span><span class="pl-kos">.</span><span class="pl-c1">file</span><span class="pl-kos">.</span><span class="pl-c1">level</span> <span class="pl-c1">=</span> <span class="pl-s">'info'</span><span class="pl-kos">;</span>

<span class="pl-s1">autoUpdater</span><span class="pl-kos">.</span><span class="pl-c1">autoDownload</span> <span class="pl-c1">=</span> <span class="pl-c1">CONFIG_DATA</span><span class="pl-kos">.</span><span class="pl-c1">updateAutoDownload</span><span class="pl-kos">;</span> <span class="pl-c">// update auto download is false.</span>
<span class="pl-s1">autoUpdater</span><span class="pl-kos">.</span><span class="pl-c1">autoInstallOnAppQuit</span> <span class="pl-c1">=</span> <span class="pl-c1">CONFIG_DATA</span><span class="pl-kos">.</span><span class="pl-c1">autoInstallOnAppQuit</span><span class="pl-kos">;</span> <span class="pl-c">// app install on quit automatically is false.</span>
<span class="pl-c">//autoUpdater.channel = 'latest';</span>

<span class="pl-s1">process</span><span class="pl-kos">.</span><span class="pl-c1">env</span><span class="pl-kos">.</span><span class="pl-c1">NODE_ENV</span> <span class="pl-c1">=</span> <span class="pl-c1">CONFIG_DATA</span><span class="pl-kos">.</span><span class="pl-c1">developmentMode</span><span class="pl-kos">;</span> <span class="pl-c">// set mode to production.</span>



<span class="pl-k">function</span> <span class="pl-en">createWindow</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-c">// Create the browser window.</span>
	
    <span class="pl-s1">win</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">BrowserWindow</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-c1">width</span>: <span class="pl-c1">CONFIG_DATA</span><span class="pl-kos">.</span><span class="pl-c1">windowWidth</span><span class="pl-kos">,</span> <span class="pl-c1">height</span>: <span class="pl-c1">CONFIG_DATA</span><span class="pl-kos">.</span><span class="pl-c1">windowHeight</span><span class="pl-kos">,</span> <span class="pl-c1">fullscreen</span>: <span class="pl-c1">CONFIG_DATA</span><span class="pl-kos">.</span><span class="pl-c1">isFullScreenScreen</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-s1">win</span><span class="pl-kos">.</span><span class="pl-en">setMenu</span><span class="pl-kos">(</span><span class="pl-c1">null</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
	
	<span class="pl-c">// Open the DevTools.</span>
    <span class="pl-s1">win</span><span class="pl-kos">.</span><span class="pl-c1">webContents</span><span class="pl-kos">.</span><span class="pl-en">openDevTools</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
	
	
    <span class="pl-c">// Emitted when the window is closed.</span>
    <span class="pl-s1">win</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'closed'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
        <span class="pl-c">// Dereference the window object, usually you would store windows</span>
        <span class="pl-c">// in an array if your app supports multi windows, this is the time</span>
        <span class="pl-c">// when you should delete the corresponding element.</span>
        <span class="pl-s1">win</span> <span class="pl-c1">=</span> <span class="pl-c1">null</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>



<span class="pl-c">// This method will be called when Electron has finished</span>
<span class="pl-c">// initialization and is ready to create browser windows.</span>
<span class="pl-c">// Some APIs can only be used after this event occurs.</span>
<span class="pl-s1">app</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'ready'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
	<span class="pl-s1">autoUpdater</span><span class="pl-kos">.</span><span class="pl-en">setFeedURL</span><span class="pl-kos">(</span><span class="pl-s1">server</span><span class="pl-kos">)</span><span class="pl-kos">;</span> 
	<span class="pl-s1">autoUpdater</span><span class="pl-kos">.</span><span class="pl-en">checkForUpdates</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// Initiate the checking for latest update.</span>
	
	<span class="pl-en">setInterval</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
		<span class="pl-s1">autoUpdater</span><span class="pl-kos">.</span><span class="pl-en">checkForUpdates</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
	<span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-c1">1000</span> <span class="pl-c1">*</span> <span class="pl-c1">60</span> <span class="pl-c1">*</span> <span class="pl-c1">3</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
	
	<span class="pl-en">createWindow</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// Create the game window.</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-c">// Quit when all windows are closed.</span>
<span class="pl-s1">app</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'window-all-closed'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-c">// On macOS it is common for applications and their menu bar</span>
    <span class="pl-c">// to stay active until the user quits explicitly with Cmd + Q</span>
    <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">process</span><span class="pl-kos">.</span><span class="pl-c1">platform</span> <span class="pl-c1">!==</span> <span class="pl-s">'darwin'</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
		<span class="pl-s1">app</span><span class="pl-kos">.</span><span class="pl-en">quit</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-s1">app</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'activate'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-c">// On macOS it's common to re-create a window in the app when the</span>
    <span class="pl-c">// dock icon is clicked and there are no other windows open.</span>
    <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">win</span> <span class="pl-c1">===</span> <span class="pl-c1">null</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
		<span class="pl-en">createWindow</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-c">// In this file you can include the rest of your app's specific main process</span>
<span class="pl-c">// code. You can also put them in separate files and require them here.</span>

<span class="pl-s1">app</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">"test"</span><span class="pl-kos">,</span><span class="pl-kos">(</span><span class="pl-s1">arg</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-s1">win</span><span class="pl-kos">.</span><span class="pl-c1">webContents</span><span class="pl-kos">.</span><span class="pl-en">print</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-c1">silent</span>: <span class="pl-c1">false</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-c">// check if update is availabel.</span>

<span class="pl-s1">autoUpdater</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'checking-for-update'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
			<span class="pl-c">// If update is availabel download it now or later.</span>
			<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'checking for update......!!!!!!'</span><span class="pl-kos">)</span>
			<span class="pl-s1">autoUpdater</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'update-available'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-s1">ev</span><span class="pl-kos">,</span><span class="pl-s1">info</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
			<span class="pl-s1">updateAvailabelPopup</span> <span class="pl-c1">=</span> <span class="pl-s1">dialog</span><span class="pl-kos">.</span><span class="pl-en">showMessageBox</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
					<span class="pl-c1">type</span>: <span class="pl-s">'info'</span><span class="pl-kos">,</span>
					<span class="pl-c1">title</span>: <span class="pl-s">'Update Availabel'</span><span class="pl-kos">,</span>
					<span class="pl-c1">messgae</span>: <span class="pl-s">'A new Update availabel. Please update now.'</span><span class="pl-kos">,</span>
					<span class="pl-c1">buttons</span>: <span class="pl-kos">[</span><span class="pl-s">'Update'</span><span class="pl-kos">,</span> <span class="pl-s">'No'</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
					<span class="pl-c1">cancelId</span>: <span class="pl-c1">1</span>
				<span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-s1">index</span><span class="pl-kos">,</span> <span class="pl-s1">val</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
					<span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-s1">index</span> <span class="pl-c1">===</span> <span class="pl-c1">1</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
						<span class="pl-c">// if user cancel update load the game.</span>
						<span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-s1">isPageLoaded</span><span class="pl-kos">)</span>
							<span class="pl-en">loadPage</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
						<span class="pl-k">return</span><span class="pl-kos">;</span>
					<span class="pl-kos">}</span><span class="pl-k">else</span><span class="pl-kos">{</span>
							<span class="pl-c">// If update have any error.</span>
							<span class="pl-s1">autoUpdater</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'error'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-s1">ev</span><span class="pl-kos">,</span> <span class="pl-s1">err</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
								<span class="pl-s1">win</span><span class="pl-kos">.</span><span class="pl-en">quit</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
							 <span class="pl-s1">errorPopup</span> <span class="pl-c1">=</span> <span class="pl-s1">dialog</span><span class="pl-kos">.</span><span class="pl-en">showMessageBox</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
									<span class="pl-c1">type</span>: <span class="pl-s">'info'</span><span class="pl-kos">,</span>
									<span class="pl-c1">title</span>: <span class="pl-s">'Error'</span><span class="pl-kos">,</span>
									<span class="pl-c1">message</span>: <span class="pl-s">'Error...'</span><span class="pl-kos">,</span>
									<span class="pl-c1">detail</span>: <span class="pl-s1">err</span><span class="pl-kos">,</span>
									<span class="pl-c1">cancelId</span>: <span class="pl-c1">1</span>
								<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
							<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
						<span class="pl-c">// Download the update.</span>
						<span class="pl-s1">autoUpdater</span><span class="pl-kos">.</span><span class="pl-en">downloadUpdate</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>	
						
						<span class="pl-c">//if( process.platform !== 'win32'){</span>
							<span class="pl-s1">progressWindow</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-s1">downloadProgressBar</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
								<span class="pl-c1">title</span>: <span class="pl-s">'Downloading Update...'</span><span class="pl-kos">,</span>
								<span class="pl-c1">text</span>: <span class="pl-s">'Downloading Update. Please Wait...'</span><span class="pl-kos">,</span>
								<span class="pl-c1">detail</span>: <span class="pl-s">'Wait...'</span><span class="pl-kos">,</span>
								<span class="pl-c1">indeterminate</span>: <span class="pl-c1">CONFIG_DATA</span><span class="pl-kos">.</span><span class="pl-c1">progressType</span>				
							<span class="pl-kos">}</span><span class="pl-kos">)</span>
							
							<span class="pl-s1">autoUpdater</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'download-progress'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">{</span>percent<span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
								<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'download progress'</span><span class="pl-kos">)</span>
								<span class="pl-s1">progressWindow</span><span class="pl-kos">.</span><span class="pl-c1">value</span> <span class="pl-c1">=</span> <span class="pl-s1">percent</span><span class="pl-kos">;</span>	
								<span class="pl-s1">downloadProgress</span> <span class="pl-c1">=</span> <span class="pl-s1">percent</span><span class="pl-kos">;</span>
							<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
							
							<span class="pl-s1">progressWindow</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'progress'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-s1">value</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
								<span class="pl-s1">progressWindow</span><span class="pl-kos">.</span><span class="pl-c1">detail</span> <span class="pl-c1">=</span> <span class="pl-s1">downloadProgress</span><span class="pl-kos">.</span><span class="pl-en">toFixed</span><span class="pl-kos">(</span><span class="pl-c1">1</span><span class="pl-kos">)</span><span class="pl-kos">;</span>		
							<span class="pl-kos">}</span><span class="pl-kos">)</span>
							
							<span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'aborted'</span><span class="pl-kos">,</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
								<span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-s1">win</span><span class="pl-kos">)</span>	<span class="pl-s1">win</span><span class="pl-kos">.</span><span class="pl-en">quit</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
							<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
						<span class="pl-c">//}</span>

						<span class="pl-c">// Update is downloaded.</span>
						<span class="pl-s1">autoUpdater</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'update-downloaded'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-s1">event</span><span class="pl-kos">,</span> <span class="pl-s1">releaseNotes</span><span class="pl-kos">,</span> <span class="pl-s1">releaseName</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
							 <span class="pl-s1">progressWindow</span><span class="pl-kos">.</span><span class="pl-en">setCompleted</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
							 <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'update downloaded'</span><span class="pl-kos">)</span>
							<span class="pl-k">const</span> <span class="pl-s1">dialogOptns</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
								<span class="pl-c1">type</span>: <span class="pl-s">'info'</span><span class="pl-kos">,</span>
								<span class="pl-c1">title</span>: <span class="pl-s">'Update Ready..!!'</span><span class="pl-kos">,</span>
								<span class="pl-c1">message</span>: <span class="pl-s1">process</span><span class="pl-kos">.</span><span class="pl-c1">platform</span> <span class="pl-c1">===</span> <span class="pl-s">'win32'</span> ? <span class="pl-s1">releaseNotes</span> : <span class="pl-s1">releaseName</span><span class="pl-kos">,</span>
								<span class="pl-c1">buttons</span>: <span class="pl-kos">[</span><span class="pl-s">'Yes'</span><span class="pl-kos">,</span> <span class="pl-s">'Later'</span><span class="pl-kos">]</span>	<span class="pl-kos">,</span>
								<span class="pl-c1">cancelId</span>: <span class="pl-c1">1</span>								
							<span class="pl-kos">}</span>
							
							<span class="pl-s1">installUpdatePopup</span> <span class="pl-c1">=</span> <span class="pl-s1">dialog</span><span class="pl-kos">.</span><span class="pl-en">showMessageBox</span><span class="pl-kos">(</span><span class="pl-s1">dialogOptns</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-s1">response</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
								<span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-s1">response</span> <span class="pl-c1">===</span> <span class="pl-c1">0</span><span class="pl-kos">)</span> <span class="pl-s1">autoUpdater</span><span class="pl-kos">.</span><span class="pl-en">quitAndInstall</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
								<span class="pl-k">else</span> <span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-s1">isPageLoaded</span><span class="pl-kos">)</span> <span class="pl-en">loadPage</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
								
							<span class="pl-kos">}</span><span class="pl-kos">)</span>			
						<span class="pl-kos">}</span><span class="pl-kos">)</span>
					<span class="pl-kos">}</span>			
				<span class="pl-kos">}</span><span class="pl-kos">)</span>
			<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
			
		
			<span class="pl-c">// Load the game if update is not availabel.</span>
			<span class="pl-s1">autoUpdater</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'update-not-available'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-s1">ev</span><span class="pl-kos">,</span><span class="pl-s1">info</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
				<span class="pl-c">// and load the index.html of the app.</span>
				<span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-s1">isPageLoaded</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
					<span class="pl-en">loadPage</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
				<span class="pl-kos">}</span>
			<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>		
			<span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-s1">isPageLoaded</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
				<span class="pl-s1">win</span><span class="pl-kos">.</span><span class="pl-en">reload</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
			<span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">function</span> <span class="pl-en">loadPage</span><span class="pl-kos">(</span><span class="pl-s1">ref</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
	<span class="pl-s1">isPageLoaded</span> <span class="pl-c1">=</span> <span class="pl-c1">true</span><span class="pl-kos">;</span>
	<span class="pl-s1">win</span><span class="pl-kos">.</span><span class="pl-en">loadFile</span><span class="pl-kos">(</span><span class="pl-s">'app/index.html'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">function</span> <span class="pl-en">cleanUp</span><span class="pl-kos">(</span><span class="pl-s1">popupArray</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
	<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">popupArray</span><span class="pl-kos">)</span>
	<span class="pl-k">for</span><span class="pl-kos">(</span><span class="pl-k">let</span> <span class="pl-s1">popup</span> <span class="pl-k">of</span> <span class="pl-s1">popupArray</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
		<span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-s1">popup</span> <span class="pl-c1">!==</span> <span class="pl-c1">null</span> <span class="pl-c1">&amp;&amp;</span> <span class="pl-s1">popup</span> <span class="pl-c1">!==</span> <span class="pl-c1">undefined</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
			<span class="pl-s1">popup</span><span class="pl-kos">.</span><span class="pl-en">destroy</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
		<span class="pl-kos">}</span>
	<span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>