1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-29 16:43:09 +03:00

Merge pull request #938 from matrix-org/travis/fail-fast-but-not-too-fast

Provide the discovered URLs when a liveliness error occurs
This commit is contained in:
Travis Ralston
2019-06-06 09:03:39 -06:00
committed by GitHub
2 changed files with 15 additions and 5 deletions

View File

@@ -275,7 +275,7 @@ describe("AutoDiscovery", function() {
"m.homeserver": { "m.homeserver": {
state: "FAIL_ERROR", state: "FAIL_ERROR",
error: AutoDiscovery.ERROR_INVALID_HOMESERVER, error: AutoDiscovery.ERROR_INVALID_HOMESERVER,
base_url: null, base_url: "https://example.org",
}, },
"m.identity_server": { "m.identity_server": {
state: "PROMPT", state: "PROMPT",
@@ -304,7 +304,7 @@ describe("AutoDiscovery", function() {
"m.homeserver": { "m.homeserver": {
state: "FAIL_ERROR", state: "FAIL_ERROR",
error: AutoDiscovery.ERROR_INVALID_HOMESERVER, error: AutoDiscovery.ERROR_INVALID_HOMESERVER,
base_url: null, base_url: "https://example.org",
}, },
"m.identity_server": { "m.identity_server": {
state: "PROMPT", state: "PROMPT",
@@ -335,7 +335,7 @@ describe("AutoDiscovery", function() {
"m.homeserver": { "m.homeserver": {
state: "FAIL_ERROR", state: "FAIL_ERROR",
error: AutoDiscovery.ERROR_INVALID_HOMESERVER, error: AutoDiscovery.ERROR_INVALID_HOMESERVER,
base_url: null, base_url: "https://example.org",
}, },
"m.identity_server": { "m.identity_server": {
state: "PROMPT", state: "PROMPT",
@@ -528,7 +528,7 @@ describe("AutoDiscovery", function() {
"m.identity_server": { "m.identity_server": {
state: "FAIL_ERROR", state: "FAIL_ERROR",
error: AutoDiscovery.ERROR_INVALID_IDENTITY_SERVER, error: AutoDiscovery.ERROR_INVALID_IDENTITY_SERVER,
base_url: null, base_url: "https://identity.example.org",
}, },
}; };
@@ -569,7 +569,7 @@ describe("AutoDiscovery", function() {
"m.identity_server": { "m.identity_server": {
state: "FAIL_ERROR", state: "FAIL_ERROR",
error: AutoDiscovery.ERROR_INVALID_IDENTITY_SERVER, error: AutoDiscovery.ERROR_INVALID_IDENTITY_SERVER,
base_url: null, base_url: "https://identity.example.org",
}, },
}; };

View File

@@ -256,6 +256,11 @@ export class AutoDiscovery {
if (!hsVersions || !hsVersions.raw["versions"]) { if (!hsVersions || !hsVersions.raw["versions"]) {
logger.error("Invalid /versions response"); logger.error("Invalid /versions response");
clientConfig["m.homeserver"].error = AutoDiscovery.ERROR_INVALID_HOMESERVER; clientConfig["m.homeserver"].error = AutoDiscovery.ERROR_INVALID_HOMESERVER;
// Supply the base_url to the caller because they may be ignoring liveliness
// errors, like this one.
clientConfig["m.homeserver"].base_url = hsUrl;
return Promise.resolve(clientConfig); return Promise.resolve(clientConfig);
} }
@@ -311,6 +316,11 @@ export class AutoDiscovery {
logger.error("Invalid /api/v1 response"); logger.error("Invalid /api/v1 response");
failingClientConfig["m.identity_server"].error = failingClientConfig["m.identity_server"].error =
AutoDiscovery.ERROR_INVALID_IDENTITY_SERVER; AutoDiscovery.ERROR_INVALID_IDENTITY_SERVER;
// Supply the base_url to the caller because they may be ignoring
// liveliness errors, like this one.
failingClientConfig["m.identity_server"].base_url = isUrl;
return Promise.resolve(failingClientConfig); return Promise.resolve(failingClientConfig);
} }
} }