@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Decrease JX.Leader lease duration from 16,000ms to 1,500ms and usurp more aggressively

Summary:
Ref T12573. `JX.Leader` synchronizes the Aphlict connection across multiple windows.

Currently, we only test to see if the leader window has been closed every 16 seconds. Instead, test every 1.5 seconds.

Also, make windows keep trying to become the leader forever. This was removed previously (in D15806) but I think that change decreased robustness here.

Test Plan:
- Opened two windows to the "Realtime" tab in DarkConsole.
- Saw one become the leader and one become a follower.
- (Optionally, wait for 10 seconds here to test the "keep trying to become the leader" behavior.)
- Closed the leader.
- Saw the follower become the leader after ~1.5 seconds.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12573

Differential Revision: https://secure.phabricator.com/D17703

+49 -39
+41 -35
resources/celerity/map.php
··· 10 10 'conpherence.pkg.css' => 'a34d59bd', 11 11 'conpherence.pkg.js' => '5f86c17d', 12 12 'core.pkg.css' => '959330a2', 13 - 'core.pkg.js' => 'deabcef7', 14 - 'darkconsole.pkg.js' => 'e7393ebb', 13 + 'core.pkg.js' => '941db947', 14 + 'darkconsole.pkg.js' => '061371d8', 15 15 'differential.pkg.css' => '90b30783', 16 16 'differential.pkg.js' => 'ddfeb49b', 17 17 'diffusion.pkg.css' => '91c5d3a6', ··· 20 20 'maniphest.pkg.css' => '4845691a', 21 21 'maniphest.pkg.js' => '5ab2753f', 22 22 'rsrc/css/aphront/aphront-bars.css' => '231ac33c', 23 - 'rsrc/css/aphront/dark-console.css' => 'f54bf286', 23 + 'rsrc/css/aphront/dark-console.css' => '07dd8d38', 24 24 'rsrc/css/aphront/dialog-view.css' => '685c7e2d', 25 25 'rsrc/css/aphront/list-filter-view.css' => '5d6f0526', 26 26 'rsrc/css/aphront/multi-column.css' => '84cc6640', ··· 234 234 'rsrc/externals/javelin/lib/DOM.js' => '805b806a', 235 235 'rsrc/externals/javelin/lib/History.js' => 'd4505101', 236 236 'rsrc/externals/javelin/lib/JSON.js' => '69adf288', 237 - 'rsrc/externals/javelin/lib/Leader.js' => 'fea0eb47', 237 + 'rsrc/externals/javelin/lib/Leader.js' => '7f243deb', 238 238 'rsrc/externals/javelin/lib/Mask.js' => '8a41885b', 239 239 'rsrc/externals/javelin/lib/Quicksand.js' => '6b8ef10b', 240 240 'rsrc/externals/javelin/lib/Request.js' => '94b750d2', ··· 363 363 'rsrc/image/texture/table_header_tall.png' => 'd56b434f', 364 364 'rsrc/js/application/aphlict/Aphlict.js' => '5359e785', 365 365 'rsrc/js/application/aphlict/behavior-aphlict-dropdown.js' => 'caade6f2', 366 - 'rsrc/js/application/aphlict/behavior-aphlict-listen.js' => 'fb20ac8d', 366 + 'rsrc/js/application/aphlict/behavior-aphlict-listen.js' => 'd82b1ff9', 367 367 'rsrc/js/application/aphlict/behavior-aphlict-status.js' => '5e2634b9', 368 368 'rsrc/js/application/aphlict/behavior-desktop-notifications-control.js' => 'd5a2d665', 369 369 'rsrc/js/application/calendar/behavior-day-view.js' => '4b3c4443', ··· 482 482 'rsrc/js/core/behavior-autofocus.js' => '7319e029', 483 483 'rsrc/js/core/behavior-badge-view.js' => '8ff5e24c', 484 484 'rsrc/js/core/behavior-choose-control.js' => '327a00d1', 485 - 'rsrc/js/core/behavior-dark-console.js' => 'f411b6ae', 486 485 'rsrc/js/core/behavior-detect-timezone.js' => '4c193c96', 487 486 'rsrc/js/core/behavior-device.js' => 'bb1dd507', 488 487 'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '484a6e22', ··· 521 520 'rsrc/js/core/behavior-user-menu.js' => '31420f77', 522 521 'rsrc/js/core/behavior-watch-anchor.js' => '9f36c42d', 523 522 'rsrc/js/core/behavior-workflow.js' => '0a3f3021', 523 + 'rsrc/js/core/darkconsole/DarkLog.js' => 'c8e1ffe3', 524 + 'rsrc/js/core/darkconsole/DarkMessage.js' => 'c48cccdd', 525 + 'rsrc/js/core/darkconsole/behavior-dark-console.js' => '3725c90c', 524 526 'rsrc/js/core/phtize.js' => 'd254d646', 525 527 'rsrc/js/phui/behavior-phui-dropdown-menu.js' => 'b95d6f7d', 526 528 'rsrc/js/phui/behavior-phui-file-upload.js' => 'b003d4fb', ··· 536 538 'symbols' => array( 537 539 'almanac-css' => 'dbb9b3af', 538 540 'aphront-bars' => '231ac33c', 539 - 'aphront-dark-console-css' => 'f54bf286', 541 + 'aphront-dark-console-css' => '07dd8d38', 540 542 'aphront-dialog-view-css' => '685c7e2d', 541 543 'aphront-list-filter-view-css' => '5d6f0526', 542 544 'aphront-multi-column-view-css' => '84cc6640', ··· 584 586 'javelin-aphlict' => '5359e785', 585 587 'javelin-behavior' => '61cbc29a', 586 588 'javelin-behavior-aphlict-dropdown' => 'caade6f2', 587 - 'javelin-behavior-aphlict-listen' => 'fb20ac8d', 589 + 'javelin-behavior-aphlict-listen' => 'd82b1ff9', 588 590 'javelin-behavior-aphlict-status' => '5e2634b9', 589 591 'javelin-behavior-aphront-basic-tokenizer' => 'b3a4b884', 590 592 'javelin-behavior-aphront-drag-and-drop-textarea' => '484a6e22', ··· 603 605 'javelin-behavior-conpherence-pontificate' => '55616e04', 604 606 'javelin-behavior-conpherence-search' => '9bbf3762', 605 607 'javelin-behavior-countdown-timer' => 'e4cc26b3', 606 - 'javelin-behavior-dark-console' => 'f411b6ae', 608 + 'javelin-behavior-dark-console' => '3725c90c', 607 609 'javelin-behavior-dashboard-async-panel' => '469c0d9e', 608 610 'javelin-behavior-dashboard-move-panels' => '408bf173', 609 611 'javelin-behavior-dashboard-query-panel-select' => '453c5375', ··· 720 722 'javelin-history' => 'd4505101', 721 723 'javelin-install' => '05270951', 722 724 'javelin-json' => '69adf288', 723 - 'javelin-leader' => 'fea0eb47', 725 + 'javelin-leader' => '7f243deb', 724 726 'javelin-magical-init' => '3010e992', 725 727 'javelin-mask' => '8a41885b', 726 728 'javelin-quicksand' => '6b8ef10b', ··· 774 776 'phabricator-content-source-view-css' => '4b8b05d4', 775 777 'phabricator-core-css' => '9f4cb463', 776 778 'phabricator-countdown-css' => '16c52f5c', 779 + 'phabricator-darklog' => 'c8e1ffe3', 780 + 'phabricator-darkmessage' => 'c48cccdd', 777 781 'phabricator-dashboard-css' => 'fe5b1869', 778 782 'phabricator-drag-and-drop-file-upload' => '58dea2fa', 779 783 'phabricator-draggable-list' => 'bea6e7f4', ··· 1118 1122 'javelin-dom', 1119 1123 'javelin-workflow', 1120 1124 ), 1125 + '3725c90c' => array( 1126 + 'javelin-behavior', 1127 + 'javelin-stratcom', 1128 + 'javelin-util', 1129 + 'javelin-dom', 1130 + 'javelin-request', 1131 + 'phabricator-keyboard-shortcut', 1132 + 'phabricator-darklog', 1133 + 'phabricator-darkmessage', 1134 + ), 1121 1135 '3ab51e2c' => array( 1122 1136 'javelin-behavior', 1123 1137 'javelin-behavior-device', ··· 1474 1488 '7ee2b591' => array( 1475 1489 'javelin-behavior', 1476 1490 'javelin-history', 1491 + ), 1492 + '7f243deb' => array( 1493 + 'javelin-install', 1477 1494 ), 1478 1495 '8018ee50' => array( 1479 1496 'javelin-install', ··· 2066 2083 'javelin-dom', 2067 2084 'phabricator-draggable-list', 2068 2085 ), 2086 + 'd82b1ff9' => array( 2087 + 'javelin-behavior', 2088 + 'javelin-aphlict', 2089 + 'javelin-stratcom', 2090 + 'javelin-request', 2091 + 'javelin-uri', 2092 + 'javelin-dom', 2093 + 'javelin-json', 2094 + 'javelin-router', 2095 + 'javelin-util', 2096 + 'javelin-leader', 2097 + 'javelin-sound', 2098 + 'phabricator-notification', 2099 + ), 2069 2100 'd835b03a' => array( 2070 2101 'javelin-behavior', 2071 2102 'javelin-dom', ··· 2173 2204 'f12cbc9f' => array( 2174 2205 'phui-oi-list-view-css', 2175 2206 ), 2176 - 'f411b6ae' => array( 2177 - 'javelin-behavior', 2178 - 'javelin-stratcom', 2179 - 'javelin-util', 2180 - 'javelin-dom', 2181 - 'javelin-request', 2182 - 'phabricator-keyboard-shortcut', 2183 - ), 2184 2207 'f50152ad' => array( 2185 2208 'phui-timeline-view-css', 2186 2209 ), ··· 2203 2226 'javelin-install', 2204 2227 'javelin-dom', 2205 2228 ), 2206 - 'fb20ac8d' => array( 2207 - 'javelin-behavior', 2208 - 'javelin-aphlict', 2209 - 'javelin-stratcom', 2210 - 'javelin-request', 2211 - 'javelin-uri', 2212 - 'javelin-dom', 2213 - 'javelin-json', 2214 - 'javelin-router', 2215 - 'javelin-util', 2216 - 'javelin-leader', 2217 - 'javelin-sound', 2218 - 'phabricator-notification', 2219 - ), 2220 2229 'fbe497e7' => array( 2221 2230 'javelin-behavior', 2222 2231 'javelin-util', ··· 2241 2250 'javelin-dom', 2242 2251 'javelin-view-visitor', 2243 2252 'javelin-util', 2244 - ), 2245 - 'fea0eb47' => array( 2246 - 'javelin-install', 2247 2253 ), 2248 2254 ), 2249 2255 'packages' => array(
+8 -4
webroot/rsrc/externals/javelin/lib/Leader.js
··· 33 33 events: ['onBecomeLeader', 'onReceiveBroadcast'], 34 34 35 35 statics: { 36 + _leaseDuration: 1500, 37 + 36 38 _interval: null, 37 39 _timeout: null, 38 40 _broadcastKey: 'JX.Leader.broadcast', ··· 130 132 // If we haven't installed an update timer yet, do so now. This will 131 133 // renew our lease every 5 seconds, making sure we hold it until the 132 134 // tab is closed. 133 - if (!self._interval && lease.until > now + 10000) { 134 - self._interval = window.setInterval(self._write, 5000); 135 + var interval = parseInt(self._leaseDuration / 3, 10); 136 + 137 + if (!self._interval && lease.until > now + (interval * 2)) { 138 + self._interval = window.setInterval(self._write, interval); 135 139 } 136 140 137 141 self._becomeLeader(); ··· 227 231 _write: function() { 228 232 var self = JX.Leader; 229 233 230 - var str = [self._id, ((+new Date()) + 16000)].join(':'); 234 + var str = [self._id, ((+new Date()) + self._leaseDuration)].join(':'); 231 235 window.localStorage.setItem(self._leaderKey, str); 232 236 }, 233 237 ··· 311 315 */ 312 316 _usurp: function() { 313 317 var self = JX.Leader; 314 - self.call(JX.bag); 315 318 self._timeout = null; 319 + self.call(JX.bag); 316 320 }, 317 321 318 322