Skip to content

Commit

Permalink
Do not error on recieveMessage if windows are closed
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Brain committed Jul 6, 2016
1 parent c44ba32 commit a49a693
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/drivers/receive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,21 @@ export function receiveMessage(event) {

registerWindow(message.source, source);

let proxyWindow = getProxy(source, message);
let proxyWindow;

try {
proxyWindow = getProxy(source, message);
} catch (err) {
return log.debug(err.message);
}

let level = POST_MESSAGE_NAMES_LIST.indexOf(message.name) !== -1 ? 'debug' : 'info';
log.logLevel(level, [ proxyWindow ? '#receiveproxy' : '#receive', message.type, message.name, message ]);

if (proxyWindow) {

if (isWindowClosed(proxyWindow)) {
throw new Error(`Target window is closed: ${message.target} - can not proxy ${message.type} ${message.name}`);
return log.debug(`Target window is closed: ${message.target} - can not proxy ${message.type} ${message.name}`);
}

delete message.target;
Expand All @@ -156,7 +162,7 @@ export function receiveMessage(event) {
}

if (isWindowClosed(source)) {
throw new Error(`Source window is closed: ${message.originalSource} - can not send ${message.type} ${message.name}`);
return log.debug(`Source window is closed: ${message.originalSource} - can not send ${message.type} ${message.name}`);
}

if (CONFIG.MOCK_MODE) {
Expand Down

0 comments on commit a49a693

Please # to comment.