私はelectronアプリを構築していて、最新バージョンのAmazon s3バケットを検索する自動更新機能を実装しようとしています。しかし、アプリを実行すると次のエラーが表示されます。
16:10:20.940 > App starting...
16:10:25.291 > isDev = false
16:10:25.341 > isElectron = true
(electron) The default value of app.allowRendererProcessReuse is deprecated, it is currently "false". It will change to be "true" in Electron 9. For more information please check https://github.com/electron/electron/issues/18397
16:10:27.024 > setting server
16:10:27.334 > creating electron window...
16:10:27.372 > Checking for update
16:10:27.380 > Checking for update...
16:10:27.390 > Checking for update...
16:10:31.295 > Error: HttpError: 403 Forbidden
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>CCAC73A34CC51E4F</RequestId><HostId>UV6SzCBOwvKCyG7LHLS3gioVz5vad+YKbaaF1oinui3a272DUf/7TDKoywjzA4YP+3jLYz3i70Q=</HostId></Error>"
Headers: {
"x-amz-request-id": "CCAC73A34CC51E4F",
"x-amz-id-2": "UV6SzCBOwvKCyG7LHLS3gioVz5vad+YKbaaF1oinui3a272DUf/7TDKoywjzA4YP+3jLYz3i70Q=",
"content-type": "application/xml",
"transfer-encoding": "chunked",
"date": "Tue, 17 Mar 2020 05:10:30 GMT",
"server": "AmazonS3"
}
at createHttpError (C:\Users\myName\Documents\myelectronapp\dist\win-unpacked\resources\app.asar\node_modules\builder-util-runtime\out\httpExecutor.js:84:10)
at IncomingMessage.<anonymous> (C:\Users\myName\Documents\myelectronapp\dist\win-unpacked\resources\app.asar\node_modules\builder-util-runtime\out\httpExecutor.js:200:18)
at IncomingMessage.emit (events.js:210:5)
at endReadableNT (_stream_readable.js:1183:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
16:10:31.312 > Error in auto-updaterHttpError: 403 Forbidden
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>CCAC73A34CC51E4F</RequestId><HostId>UV6SzCBOwvKCyG7LHLS3gioVz5vad+YKbaaF1oinui3a272DUf/7TDKoywjzA4YP+3jLYz3i70Q=</HostId></Error>"
Headers: {
"x-amz-request-id": "CCAC73A34CC51E4F",
"x-amz-id-2": "UV6SzCBOwvKCyG7LHLS3gioVz5vad+YKbaaF1oinui3a272DUf/7TDKoywjzA4YP+3jLYz3i70Q=",
"content-type": "application/xml",
"transfer-encoding": "chunked",
"date": "Tue, 17 Mar 2020 05:10:30 GMT",
"server": "AmazonS3"
}
16:10:31.335 > Error in auto-updater. HttpError: 403 Forbidden
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>CCAC73A34CC51E4F</RequestId><HostId>UV6SzCBOwvKCyG7LHLS3gioVz5vad+YKbaaF1oinui3a272DUf/7TDKoywjzA4YP+3jLYz3i70Q=</HostId></Error>"
Headers: {
"x-amz-request-id": "CCAC73A34CC51E4F",
"x-amz-id-2": "UV6SzCBOwvKCyG7LHLS3gioVz5vad+YKbaaF1oinui3a272DUf/7TDKoywjzA4YP+3jLYz3i70Q=",
"content-type": "application/xml",
"transfer-encoding": "chunked",
"date": "Tue, 17 Mar 2020 05:10:30 GMT",
"server": "AmazonS3"
}
(node:46716) UnhandledPromiseRejectionWarning: HttpError: 403 Forbidden
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>CCAC73A34CC51E4F</RequestId><HostId>UV6SzCBOwvKCyG7LHLS3gioVz5vad+YKbaaF1oinui3a272DUf/7TDKoywjzA4YP+3jLYz3i70Q=</HostId></Error>"
Headers: {
"x-amz-request-id": "CCAC73A34CC51E4F",
"x-amz-id-2": "UV6SzCBOwvKCyG7LHLS3gioVz5vad+YKbaaF1oinui3a272DUf/7TDKoywjzA4YP+3jLYz3i70Q=",
"content-type": "application/xml",
"transfer-encoding": "chunked",
"date": "Tue, 17 Mar 2020 05:10:30 GMT",
"server": "AmazonS3"
}
at createHttpError (C:\Users\myName\Documents\myelectronapp\dist\win-unpacked\resources\app.asar\node_modules\builder-util-runtime\out\httpExecutor.js:84:10)
at IncomingMessage.<anonymous> (C:\Users\myName\Documents\myelectronapp\dist\win-unpacked\resources\app.asar\node_modules\builder-util-runtime\out\httpExecutor.js:200:18)
at IncomingMessage.emit (events.js:210:5)
at endReadableNT (_stream_readable.js:1183:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
(node:46716) UnhandledPromiseRejectionWarning: HttpError: 403 Forbidden
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>CCAC73A34CC51E4F</RequestId><HostId>UV6SzCBOwvKCyG7LHLS3gioVz5vad+YKbaaF1oinui3a272DUf/7TDKoywjzA4YP+3jLYz3i70Q=</HostId></Error>"
Headers: {
"x-amz-request-id": "CCAC73A34CC51E4F",
"x-amz-id-2": "UV6SzCBOwvKCyG7LHLS3gioVz5vad+YKbaaF1oinui3a272DUf/7TDKoywjzA4YP+3jLYz3i70Q=",
"content-type": "application/xml",
"transfer-encoding": "chunked",
"date": "Tue, 17 Mar 2020 05:10:30 GMT",
"server": "AmazonS3"
}
at createHttpError (C:\Users\myName\Documents\myelectronapp\dist\win-unpacked\resources\app.asar\node_modules\builder-util-runtime\out\httpExecutor.js:84:10)
at IncomingMessage.<anonymous> (C:\Users\myName\Documents\myelectronapp\dist\win-unpacked\resources\app.asar\node_modules\builder-util-runtime\out\httpExecutor.js:200:18)
at IncomingMessage.emit (events.js:210:5)
at endReadableNT (_stream_readable.js:1183:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
(node:46716) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:46716) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:46716) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:46716) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Awsトークンが使用されていないことに関係していると思いますか?それらは私の.envファイルにありますが、electron-builderがこれをどのように取得しているかはわかりません
.env
AWS_ACCESS_KEY_ID=<exampleKeyId>
AWS_SECRET_ACCESS_KEY=<exampleAccessKey>
package.json-ビルド
"build": {
"appId": "com.myname.electron-app",
"productName": "myElectronApp",
"copyright": "Copyright © 2019 ${author}",
"mac": {
"category": "public.app-category.utilities"
},
"files": [
"build/**/*",
"node_modules/**/*"
],
"directories": {
"buildResources": "assets"
},
"publish": {
"provider": "s3",
"bucket": "mybucketname"
}
}
メインelectron.jsファイル
const { ipcMain, app, BrowserWindow, ipcRenderer } = require('electron');
const path = require('path');
const isDev = require('electron-is-dev');
const os = require('os');
const { autoUpdater } = require('electron-updater');
const isElectron = require('is-electron');
const log = require('electron-log');
//Load Dev only modules
// if(isDev) {
// require('electron-reload');
// require('dotenv').load();
// }
let mainWindow;
let serverWindow;
autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = 'info';
log.info('App starting...');
log.info('isDev = ', isDev);
log.info('isElectron = ', isElectron());
function createWindow() {
log.info('creating electron window...');
mainWindow = new BrowserWindow({
width: 1500,
height: 680,
webPreferences: {
nodeIntegration: true,
},
});
mainWindow.loadURL(isDev ? `http://localhost:3000/` : `file://${path.join(__dirname, '../build/index.html')}`);
if (isDev) {
//BrowserWindow.addDevToolsExtension('<location to your react chrome extension>');
mainWindow.webContents.openDevTools();
if (isElectron()) {
//Install Dev Tools using just Electron
BrowserWindow.addDevToolsExtension(
path.join(os.homedir(), '/AppData/Local/Google/Chrome/User Data/Default/Extensions/lmhkpmbekcpmknklioeibfkpmmfibljd/2.17.0_0')
)
BrowserWindow.addDevToolsExtension(
path.join(os.homedir(), '/AppData/Local/Google/Chrome/User Data/Default/Extensions/fmkadmapgofadopljbjfkapdkoienihi/4.4.0_0')
)
}
}
mainWindow.on('closed', () => mainWindow = null);
}
function startExpress() {
log.info('setting server');
//Create the server window.
serverWindow = new BrowserWindow(
{
width: 1500,
height: 680,
webPreferences: {
nodeIntegration: true,
}
}
// :
// {
// show: false
// }
);
// if(isDev) { serverWindow.webContents.openDevTools(); }
//console.log('server path', `file://${path.join(__dirname, '\\server\\server.html')}`);
serverWindow.loadURL(`file://${path.join(__dirname, '\\server\\server.html')}`)
}
app.on('ready', () => {
startExpress();
createWindow();
autoUpdater.checkForUpdatesAndNotify();
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (mainWindow === null) {
createWindow();
}
});
ipcMain.on('catch-on-main', (event, args) => {
//Do stuff
})
ipcMain.on('get-app-version', (event) => {
console.log('appversion=', app.getVersion());
mainWindow.webContents.send('set-app-version', app.getVersion());
});
ipcMain.on('restart-app', () => {
console.log('restarting the app...');
autoUpdater.quitAndInstall();
});
ipcMain.on('server-running', () => {
console.log('ipcMain channel entered server-running');
mainWindow.webContents.send('relay-server-running');
})
autoUpdater.on('checking-for-update', () => {
log.info('Checking for update...');
sendStatusToWindow('Checking for update...');
})
autoUpdater.on('update-available', (info) => {
log.info('Update available');
sendStatusToWindow('Update available.');
})
autoUpdater.on('update-not-available', (info) => {
log.info('Update not available.');
sendStatusToWindow('Update not available.');
})
autoUpdater.on('download-update', () => {
log.info('downloading update...');
sendStatusToWindow('download-update.');
});
autoUpdater.on('error', (err) => {
log.info('Error in auto-updater' + err);
sendStatusToWindow('Error in auto-updater. ' + err);
})
autoUpdater.on('download-progress', (progressObj) => {
let log_message = "Download speed: " + progressObj.bytesPerSecond;
log_message = log_message + ' - Downloaded ' + progressObj.percent + '%';
log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')';
log.info(log_message);
sendStatusToWindow(log_message);
})
autoUpdater.on('update-downloaded', (info) => {
log.info('Update downloaded.');
sendStatusToWindow('Update downloaded');
});
function sendStatusToWindow(text) {
log.info(text);
mainWindow.webContents.send('message', text);
}
理由は、秘密鍵を含む.envファイルをビルドに含めなかったためです。