Sentry fix: race condition can cause finalize to be called after captureWindow destroyed

This commit is contained in:
Ben Gotow 2019-06-16 13:34:54 -05:00
parent 3994c6e67f
commit acfe38e485

View file

@ -323,7 +323,9 @@ function _generateNextCrossplatformPreview() {
onFinalize = success => { onFinalize = success => {
clearTimeout(timer); clearTimeout(timer);
captureWindow.removeListener('page-title-updated', onRendererSuccess); if (captureWindow) {
captureWindow.removeListener('page-title-updated', onRendererSuccess);
}
process.nextTick(_generateNextCrossplatformPreview); process.nextTick(_generateNextCrossplatformPreview);
resolve(success); resolve(success);
}; };
@ -336,9 +338,7 @@ async function _generateQuicklookPreview({ filePath }: { filePath: string }) {
const pathQuoted = `"${filePath.replace(/"/g, '\\"')}"`; const pathQuoted = `"${filePath.replace(/"/g, '\\"')}"`;
return new Promise(resolve => { return new Promise(resolve => {
const cmd = `qlmanage -t -f ${ const cmd = `qlmanage -t -f ${window.devicePixelRatio} -s ${ThumbnailWidth} -o ${dirQuoted} ${pathQuoted}`;
window.devicePixelRatio
} -s ${ThumbnailWidth} -o ${dirQuoted} ${pathQuoted}`;
exec(cmd, (error, stdout, stderr) => { exec(cmd, (error, stdout, stderr) => {
// Note: sometimes qlmanage outputs to stderr but still successfully // Note: sometimes qlmanage outputs to stderr but still successfully