Skip to content

Commit

Permalink
Merge branch 'fix-problem-report' into prepare-2018.1
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Mar 1, 2018
2 parents 13651b5 + 2a2dd81 commit a7a6a68
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 38 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
## [Unreleased]


## [2018.1] - 2018-02-27
Identical to 2018.1-beta10, just removing the beta label.
## [2018.1] - 2018-03-01
### Changed
- Redact all account numbers in the account number history from problem reports instead of only the
currently logged in one.

### Fixed
- Increase a timeout for problem report collection to fix a timeout error on slower machines.
- Fix a memory leak in the problem report collection routine.
- Fix an issue when viewing a problem report brought up a dialog to choose the application to open
the file.


## [2018.1-beta10] - 2018-02-13
Expand Down
10 changes: 3 additions & 7 deletions app/components/Support.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,12 @@ export default class Support extends Component {
});
}

_getLog() {
const toRedact = [];
if (this.props.account.accountToken) {
toRedact.push(this.props.account.accountToken.toString());
}

_getLog(): Promise<string> {
const accountsToRedact = this.props.account.accountHistory;
const { savedReport } = this.state;
return savedReport ?
Promise.resolve(savedReport) :
this.props.onCollectLog(toRedact)
this.props.onCollectLog(accountsToRedact)
.then( path => {
return new Promise(resolve => this.setState({ savedReport: path }, () => resolve(path)));
});
Expand Down
59 changes: 31 additions & 28 deletions app/lib/problem-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,42 @@ import { ipcRenderer } from 'electron';
import { log } from './platform';
import uuid from 'uuid';

const collectProblemReport = (toRedact: string) => {
const unAnsweredIpcCalls = new Map();
function reapIpcCall(id) {
const promise = unAnsweredIpcCalls.get(id);
unAnsweredIpcCalls.delete(id);
const collectProblemReport = (toRedact: Array<string>): Promise<string> => {
return new Promise((resolve, reject) => {
const requestId = uuid.v4();
let responseListener: Function;

const removeResponseListener = () => {
ipcRenderer.removeListener('collect-logs-reply', responseListener);
};

// timeout after 10 seconds if no ipc response received
const requestTimeout = setTimeout(() => {
removeResponseListener();
log.error('Timed out when collecting a problem report');
reject(new Error('Timed out'));
}, 10000);

if (promise) {
promise.reject(new Error('Timed out'));
}
}
ipcRenderer.on('collect-logs-reply', (_event, id, err, reportId) => {
const promise = unAnsweredIpcCalls.get(id);
unAnsweredIpcCalls.delete(id);
if(promise) {
if(err) {
promise.reject(err);
responseListener = (_event, id, error, reportPath) => {
if(id !== requestId) { return; }

clearTimeout(requestTimeout);
removeResponseListener();

if(error) {
log.error(`Cannot collect a problem report: ${ error.err }`);
log.error(`Stdout: ${ error.stdout }`);
reject(error);
} else {
promise.resolve(reportId);
resolve(reportPath);
}
}
});
return new Promise((resolve, reject) => {
};

const id = uuid.v4();
unAnsweredIpcCalls.set(id, { resolve, reject });
ipcRenderer.send('collect-logs', id, toRedact);
setTimeout(() => reapIpcCall(id), 1000);
}).catch((e) => {
const { err, stdout } = e;
log.error('Failed collecting problem report', err);
log.error(' stdout: ' + stdout);
// add ipc response listener
ipcRenderer.on('collect-logs-reply', responseListener);

throw e;
// send ipc request
ipcRenderer.send('collect-logs', requestId, toRedact);
});
};

Expand Down
2 changes: 1 addition & 1 deletion app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const appDelegate = {

const logFiles = files.filter(file => file.endsWith('.log'))
.map(f => path.join(appDelegate._logFileLocation, f));
const reportPath = path.join(writableDirectory, uuid.v4() + '.report');
const reportPath = path.join(writableDirectory, uuid.v4() + '.log');

const binPath = resolveBin('problem-report');
let args = [
Expand Down

0 comments on commit a7a6a68

Please sign in to comment.