Repository: syncthing/syncthing
File: gui/default/syncthing/core/syncthingController.js (JavaScript)

Code before:
        }

        function refreshErrors() {
            $http.get(urlbase + '/system/error').success(function (data) {
                $scope.errors = data.errors;
                console.log("refreshErrors", data);
            }).error($scope.emitHTTPError);
        }

        function refreshConfig() {
            $http.get(urlbase + '/system/config').success(function (data) {
                updateLocalConfig(data);
                console.log("refreshConfig", data);
            }).error($scope.emitHTTPError);

            $http.get(urlbase + '/system/config/insync').success(function (data) {
                $scope.configInSync = data.configInSync;
            }).error($scope.emitHTTPError);
        }

        $scope.probeAddress = function (address) {
            let response = $http({
                method: "OPTIONS",
                url: address,
            });
            return response.$$state.status >= 200 && response.$$state.status < 300;
        }

        $scope.refreshNeed = function (page, perpage) {
            if (!$scope.neededFolder) {
                return;
            }
            var url = urlbase + "/db/need?folder=" + encodeURIComponent($scope.neededFolder);
            url += "&page=" + page;
            url += "&perpage=" + perpage;
            $http.get(url).success(function (data) {
                console.log("refreshNeed", $scope.neededFolder, data);
                parseNeeded(data);
            }).error($scope.emitHTTPError);
        }

        function needAction(file) {
            var fDelete = 4096;
            var fDirectory = 16384;

            if ((file.flags & (fDelete + fDirectory)) === fDelete + fDirectory) {
                return 'rmdir';
            } else if ((file.flags & fDelete) === fDelete) {
                return 'rm';
            } else if ((file.flags & fDirectory) === fDirectory) {
                return 'touch';

Review comment (bug):
I think some `success()` or `error()` promise must be involved here. I debugged this function and `response.$$state.status` was always zero, explaining why it always said "Unreachable".

Code after:
                }
                var newAddress = "http://" + replaceAddressPort(connections[id].address, port);
                if (!(newAddress in $scope.remoteGUICache)) {
                    // No cached result, trigger a new port probing asynchronously
                    $scope.probeRemoteGUIAddress(id, newAddress);
                } else {
                    newCache[newAddress] = $scope.remoteGUICache[newAddress];
                    // Copy cached probing result in the corner case of duplicate GUI
                    // addresses for different devices.  Which is useless, but
                    // possible when behind the same NAT router.
                    if (newCache[newAddress]) {
                        $scope.idToRemoteGUI[id] = newAddress;
                    } else {
                        $scope.idToRemoteGUI[id] = "";
                    }
                }
            }
            // Replace the cache to discard stale addresses
            $scope.remoteGUICache = newCache;
        }

        function refreshErrors() {
            $http.get(urlbase + '/system/error').success(function (data) {
                $scope.errors = data.errors;
                console.log("refreshErrors", data);
            }).error($scope.emitHTTPError);
        }

        function refreshConfig() {
            $http.get(urlbase + '/config').success(function (data) {
                updateLocalConfig(data);
                console.log("refreshConfig", data);
            }).error($scope.emitHTTPError);

            $http.get(urlbase + '/config/insync').success(function (data) {
                $scope.configInSync = data.configInSync;
            }).error($scope.emitHTTPError);
        }

        $scope.probeRemoteGUIAddress = function (deviceId, address) {
            // Strip off possible IPv6 link-local zone identifier, as Angular chokes on it
            // with an (ugly, unjustified) console error message.
            var urlAddress = address.replace(/%[a-zA-Z0-9_\.\-]*\]/, ']');
            $http({
                method: "OPTIONS",
                url: urlAddress,
            }).success(function (data) {
                $scope.remoteGUICache[address] = true;
                $scope.idToRemoteGUI[deviceId] = address;
            }).error(function (err) {
                $scope.remoteGUICache[address] = false;