Merge pull request #9960 from vector-im/travis/fail-fast-but-not-too-fast
Do not fail on server liveliness checks during startup
This commit is contained in:
commit
f5e5ad9670
4 changed files with 50 additions and 19 deletions
|
@ -113,10 +113,10 @@ For a good example, see https://riot.im/develop/config.json.
|
||||||
Riot to use. The object is the same as returned by [https://<server_name>/.well-known/matrix/client](https://matrix.org/docs/spec/client_server/latest.html#get-well-known-matrix-client),
|
Riot to use. The object is the same as returned by [https://<server_name>/.well-known/matrix/client](https://matrix.org/docs/spec/client_server/latest.html#get-well-known-matrix-client),
|
||||||
with added support for a `server_name` under the `m.homeserver` section to display
|
with added support for a `server_name` under the `m.homeserver` section to display
|
||||||
a custom homeserver name. Alternatively, the config can contain a `default_server_name`
|
a custom homeserver name. Alternatively, the config can contain a `default_server_name`
|
||||||
instead which is where Riot will go to get that same object - see the `.well-known`
|
instead which is where Riot will go to get that same object, although this option is
|
||||||
link above for more information. Note that the `default_server_name` is used to get
|
deprecated - see the `.well-known` link above for more information on using this option.
|
||||||
a complete server configuration whereas the `server_name` in the `default_server_config`
|
Note that the `default_server_name` is used to get a complete server configuration
|
||||||
is for display purposes only.
|
whereas the `server_name` in the `default_server_config` is for display purposes only.
|
||||||
* *Note*: The URLs can also be individually specified as `default_hs_url` and
|
* *Note*: The URLs can also be individually specified as `default_hs_url` and
|
||||||
`default_is_url`, however these are deprecated. They are maintained for backwards
|
`default_is_url`, however these are deprecated. They are maintained for backwards
|
||||||
compatibility with older configurations. `default_is_url` is respected only
|
compatibility with older configurations. `default_is_url` is respected only
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"Unexpected error preparing the app. See console for details.": "Unexpected error preparing the app. See console for details.",
|
"Unexpected error preparing the app. See console for details.": "Unexpected error preparing the app. See console for details.",
|
||||||
"This installation of Riot seems to have an invalid server configuration. If you are the administrator, please correct the error below": "This installation of Riot seems to have an invalid server configuration. If you are the administrator, please correct the error below",
|
"Your Riot is misconfigured": "Your Riot is misconfigured",
|
||||||
"Invalid configuration: can only specify one of default_server_config, default_server_name, or default_hs_url.": "Invalid configuration: can only specify one of default_server_config, default_server_name, or default_hs_url.",
|
"Invalid configuration: can only specify one of default_server_config, default_server_name, or default_hs_url.": "Invalid configuration: can only specify one of default_server_config, default_server_name, or default_hs_url.",
|
||||||
"Invalid configuration: no default server specified.": "Invalid configuration: no default server specified.",
|
"Invalid configuration: no default server specified.": "Invalid configuration: no default server specified.",
|
||||||
"Riot Desktop on %(platformName)s": "Riot Desktop on %(platformName)s",
|
"Riot Desktop on %(platformName)s": "Riot Desktop on %(platformName)s",
|
||||||
|
|
|
@ -368,20 +368,12 @@ async function loadApp() {
|
||||||
|
|
||||||
let errorMessage = err.translatedMessage
|
let errorMessage = err.translatedMessage
|
||||||
|| _t("Unexpected error preparing the app. See console for details.");
|
|| _t("Unexpected error preparing the app. See console for details.");
|
||||||
errorMessage = <span>
|
errorMessage = <span>{errorMessage}</span>;
|
||||||
{_t(
|
|
||||||
"This installation of Riot seems to have an invalid server configuration. " +
|
|
||||||
"If you are the administrator, please correct the error below",
|
|
||||||
)}
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
{errorMessage}
|
|
||||||
</span>;
|
|
||||||
|
|
||||||
// Like the compatibility page, AWOOOOOGA at the user
|
// Like the compatibility page, AWOOOOOGA at the user
|
||||||
const GenericErrorPage = sdk.getComponent("structures.GenericErrorPage");
|
const GenericErrorPage = sdk.getComponent("structures.GenericErrorPage");
|
||||||
window.matrixChat = ReactDOM.render(
|
window.matrixChat = ReactDOM.render(
|
||||||
<GenericErrorPage message={errorMessage} />,
|
<GenericErrorPage message={errorMessage} title={_t("Your Riot is misconfigured")} />,
|
||||||
document.getElementById('matrixchat'),
|
document.getElementById('matrixchat'),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -465,6 +457,11 @@ async function verifyServerConfig() {
|
||||||
// context of email validation. Because we don't respect them otherwise, we do not need
|
// context of email validation. Because we don't respect them otherwise, we do not need
|
||||||
// to parse or consider them here.
|
// to parse or consider them here.
|
||||||
|
|
||||||
|
// Note: Although we throw all 3 possible configuration options through a .well-known-style
|
||||||
|
// verification, we do not care if the servers are online at this point. We do moderately
|
||||||
|
// care if they are syntactically correct though, so we shove them through the .well-known
|
||||||
|
// validators for that purpose.
|
||||||
|
|
||||||
const config = SdkConfig.get();
|
const config = SdkConfig.get();
|
||||||
let wkConfig = config['default_server_config']; // overwritten later under some conditions
|
let wkConfig = config['default_server_config']; // overwritten later under some conditions
|
||||||
const serverName = config['default_server_name'];
|
const serverName = config['default_server_name'];
|
||||||
|
@ -486,6 +483,10 @@ async function verifyServerConfig() {
|
||||||
|
|
||||||
if (hsUrl) {
|
if (hsUrl) {
|
||||||
console.log("Config uses a default_hs_url - constructing a default_server_config using this information");
|
console.log("Config uses a default_hs_url - constructing a default_server_config using this information");
|
||||||
|
console.warn(
|
||||||
|
"DEPRECATED CONFIG OPTION: In the future, default_hs_url will not be accepted. Please use " +
|
||||||
|
"default_server_config instead.",
|
||||||
|
);
|
||||||
|
|
||||||
wkConfig = {
|
wkConfig = {
|
||||||
"m.homeserver": {
|
"m.homeserver": {
|
||||||
|
@ -507,10 +508,14 @@ async function verifyServerConfig() {
|
||||||
|
|
||||||
if (serverName) {
|
if (serverName) {
|
||||||
console.log("Config uses a default_server_name - doing .well-known lookup");
|
console.log("Config uses a default_server_name - doing .well-known lookup");
|
||||||
|
console.warn(
|
||||||
|
"DEPRECATED CONFIG OPTION: In the future, default_server_name will not be accepted. Please " +
|
||||||
|
"use default_server_config instead.",
|
||||||
|
);
|
||||||
discoveryResult = await AutoDiscovery.findClientConfig(serverName);
|
discoveryResult = await AutoDiscovery.findClientConfig(serverName);
|
||||||
}
|
}
|
||||||
|
|
||||||
validatedConfig = AutoDiscoveryUtils.buildValidatedConfigFromDiscovery(serverName, discoveryResult);
|
validatedConfig = AutoDiscoveryUtils.buildValidatedConfigFromDiscovery(serverName, discoveryResult, true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const {hsUrl, isUrl, userId} = Lifecycle.getLocalStorageSessionVars();
|
const {hsUrl, isUrl, userId} = Lifecycle.getLocalStorageSessionVars();
|
||||||
if (hsUrl && userId) {
|
if (hsUrl && userId) {
|
||||||
|
@ -518,7 +523,7 @@ async function verifyServerConfig() {
|
||||||
console.warn("A session was found - suppressing config error and using the session's homeserver");
|
console.warn("A session was found - suppressing config error and using the session's homeserver");
|
||||||
|
|
||||||
console.log("Using pre-existing hsUrl and isUrl: ", {hsUrl, isUrl});
|
console.log("Using pre-existing hsUrl and isUrl: ", {hsUrl, isUrl});
|
||||||
validatedConfig = await AutoDiscoveryUtils.validateServerConfigWithStaticUrls(hsUrl, isUrl);
|
validatedConfig = await AutoDiscoveryUtils.validateServerConfigWithStaticUrls(hsUrl, isUrl, true);
|
||||||
} else {
|
} else {
|
||||||
// the user is not logged in, so scream
|
// the user is not logged in, so scream
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -240,6 +240,10 @@ describe('loading:', function() {
|
||||||
uriFragment: "#/room/!room:id",
|
uriFragment: "#/room/!room:id",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Pass the liveliness checks
|
||||||
|
httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]});
|
||||||
|
httpBackend.when("GET", "/api/v1").respond(200, {});
|
||||||
|
|
||||||
Promise.delay(1).then(() => {
|
Promise.delay(1).then(() => {
|
||||||
// at this point, we're trying to do a guest registration;
|
// at this point, we're trying to do a guest registration;
|
||||||
// we expect a spinner
|
// we expect a spinner
|
||||||
|
@ -277,6 +281,10 @@ describe('loading:', function() {
|
||||||
uriFragment: "#/login",
|
uriFragment: "#/login",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Pass the liveliness checks
|
||||||
|
httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]});
|
||||||
|
httpBackend.when("GET", "/api/v1").respond(200, {});
|
||||||
|
|
||||||
return awaitLoginComponent(matrixChat).then(() => {
|
return awaitLoginComponent(matrixChat).then(() => {
|
||||||
// we expect a single <Login> component
|
// we expect a single <Login> component
|
||||||
ReactTestUtils.findRenderedComponentWithType(
|
ReactTestUtils.findRenderedComponentWithType(
|
||||||
|
@ -285,8 +293,13 @@ describe('loading:', function() {
|
||||||
// the only outstanding request should be a GET /login
|
// the only outstanding request should be a GET /login
|
||||||
// (in particular there should be no /register request for
|
// (in particular there should be no /register request for
|
||||||
// guest registration).
|
// guest registration).
|
||||||
|
const allowedRequests = [
|
||||||
|
"/_matrix/client/r0/login",
|
||||||
|
"/versions",
|
||||||
|
"/api/v1",
|
||||||
|
];
|
||||||
for (const req of httpBackend.requests) {
|
for (const req of httpBackend.requests) {
|
||||||
if (req.method === 'GET' && req.path.endsWith('/_matrix/client/r0/login')) {
|
if (req.method === 'GET' && allowedRequests.find(p => req.path.endsWith(p))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,6 +400,10 @@ describe('loading:', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows a login view', function() {
|
it('shows a login view', function() {
|
||||||
|
// Pass the liveliness checks
|
||||||
|
httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]});
|
||||||
|
httpBackend.when("GET", "/api/v1").respond(200, {});
|
||||||
|
|
||||||
// we expect a single <Login> component
|
// we expect a single <Login> component
|
||||||
ReactTestUtils.findRenderedComponentWithType(
|
ReactTestUtils.findRenderedComponentWithType(
|
||||||
matrixChat, sdk.getComponent('structures.auth.Login'),
|
matrixChat, sdk.getComponent('structures.auth.Login'),
|
||||||
|
@ -395,8 +412,13 @@ describe('loading:', function() {
|
||||||
// the only outstanding request should be a GET /login
|
// the only outstanding request should be a GET /login
|
||||||
// (in particular there should be no /register request for
|
// (in particular there should be no /register request for
|
||||||
// guest registration, nor /sync, etc).
|
// guest registration, nor /sync, etc).
|
||||||
|
const allowedRequests = [
|
||||||
|
"/_matrix/client/r0/login",
|
||||||
|
"/versions",
|
||||||
|
"/api/v1",
|
||||||
|
];
|
||||||
for (const req of httpBackend.requests) {
|
for (const req of httpBackend.requests) {
|
||||||
if (req.method === 'GET' && req.path.endsWith('/_matrix/client/r0/login')) {
|
if (req.method === 'GET' && allowedRequests.find(p => req.path.endsWith(p))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,6 +427,10 @@ describe('loading:', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows the homepage after login', function() {
|
it('shows the homepage after login', function() {
|
||||||
|
// Pass the liveliness checks
|
||||||
|
httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]});
|
||||||
|
httpBackend.when("GET", "/api/v1").respond(200, {});
|
||||||
|
|
||||||
return completeLogin(matrixChat).then(() => {
|
return completeLogin(matrixChat).then(() => {
|
||||||
// we should see a home page, even though we previously had
|
// we should see a home page, even though we previously had
|
||||||
// a stored mx_last_room_id
|
// a stored mx_last_room_id
|
||||||
|
|
Loading…
Reference in a new issue