diff --git a/package.json b/package.json index 3ecaaffd..2e5f3fd1 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "c9.ide.language.javascript.tern": "#2b0bb024da", "c9.ide.language.javascript.infer": "#cfec494a3c", "c9.ide.language.jsonalyzer": "#ba3e0d298c", - "c9.ide.collab": "#ca8cc53a66", + "c9.ide.collab": "#6d1ce4ec15", "c9.ide.local": "#a9703b630c", "c9.ide.find": "#6cc6d3379d", "c9.ide.find.infiles": "#72582de3cd", diff --git a/plugins/c9.ide.editors/tab.js b/plugins/c9.ide.editors/tab.js index 1c197575..5edb173f 100644 --- a/plugins/c9.ide.editors/tab.js +++ b/plugins/c9.ide.editors/tab.js @@ -15,6 +15,7 @@ define(function(require, module, exports) { title, tooltip, amlTab, closed, rule, docInited; var meta = {}; + var debugData = {}; var name = options.name; var classList = { @@ -355,6 +356,13 @@ define(function(require, module, exports) { * @property {Object} meta */ get meta(){ return meta; }, + + /** + * Data for debugging issues and errors with tabs + * @property {Object} debugData + */ + get debugData(){ return debugData; }, + /** * The path to the file loaded into this tab. This property will * be undefined when no path is set (for instance when no file diff --git a/plugins/c9.ide.watcher/gui.js b/plugins/c9.ide.watcher/gui.js index b50cabfc..ff41969f 100644 --- a/plugins/c9.ide.watcher/gui.js +++ b/plugins/c9.ide.watcher/gui.js @@ -1,7 +1,7 @@ define(function(require, exports, module) { main.consumes = [ "Plugin", "fs", "settings", "preferences", "watcher", "tabManager", - "save", "dialog.question", "dialog.filechange", "threewaymerge" + "save", "dialog.question", "dialog.filechange", "threewaymerge", "error_handler" ]; main.provides = ["watcher.gui"]; return main; @@ -17,6 +17,7 @@ define(function(require, exports, module) { var question = imports["dialog.question"]; var filechange = imports["dialog.filechange"]; var threeWayMerge = imports.threewaymerge.merge; + var errorHandler = imports.error_handler; var collabEnabled = options.collab; @@ -127,6 +128,23 @@ define(function(require, exports, module) { // Collab is supposed to handle this change // TODO make this a setting console.warn("[watchers] change ignored because of Collab", e.path); + /* If the lastChange (added by collab) was greater than 1 second ago set up a watch + To ensure that collab makes this change, if not report an error. The lastChange + check is to avoid a race condition if collab updates before this function runs */ + if (!tab.debugData.lastChange || tab.debugData.lastChange < (Date.now() - 1000)) { + if (tab.debugData.changeRegistered) { + clearTimeout(tab.debugData.changeRegistered); + } + tab.debugData.changeRegistered = setTimeout(function() { + errorHandler.reportError(new Error("Watcher picked up file change but collab didn't apply it"), { + active: tab.active, + state: tab.getState(), + collabEnabled: collabEnabled, + lastChange: tab.debugData.lastChange, + currentTime: Date.now(), + }); + }, 5000); + } return; }