diff --git a/README.md b/README.md index f4171b0..2e4c00e 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ The main entry point is [src/service-worker/main.ts](src/service-worker/main.ts) ``` ├── src │   ├── landing-page - splash screen displayed to users when making request to domain node, initializing service worker and fetching content from content nodes -│   │   └── armada +│   │   └── earthfast │   │   ├── fonts │   │   ├── images │   │   └── styles diff --git a/cypress/e2e/manifest-failure.cy.ts b/cypress/e2e/manifest-failure.cy.ts index 709dd32..686948e 100644 --- a/cypress/e2e/manifest-failure.cy.ts +++ b/cypress/e2e/manifest-failure.cy.ts @@ -10,6 +10,7 @@ it('manifest fetch on content nodes failure', () => { harness.intercept(); harness.spyOnMessages(window); + content0.failResource('earthfast.json'); content0.failResource('armada.json'); cy.visit(harness.domainNode.url); diff --git a/cypress/fixtures/checksum-mismatch/e2e/armada.json b/cypress/fixtures/checksum-mismatch/e2e/earthfast.json similarity index 100% rename from cypress/fixtures/checksum-mismatch/e2e/armada.json rename to cypress/fixtures/checksum-mismatch/e2e/earthfast.json diff --git a/cypress/fixtures/content-does-not-exist/e2e/armada.json b/cypress/fixtures/content-does-not-exist/e2e/earthfast.json similarity index 100% rename from cypress/fixtures/content-does-not-exist/e2e/armada.json rename to cypress/fixtures/content-does-not-exist/e2e/earthfast.json diff --git a/cypress/fixtures/css-relative-url/e2e/armada.json b/cypress/fixtures/css-relative-url/e2e/earthfast.json similarity index 100% rename from cypress/fixtures/css-relative-url/e2e/armada.json rename to cypress/fixtures/css-relative-url/e2e/earthfast.json diff --git a/cypress/fixtures/subdirectory-index/e2e/armada.json b/cypress/fixtures/subdirectory-index/e2e/earthfast.json similarity index 100% rename from cypress/fixtures/subdirectory-index/e2e/armada.json rename to cypress/fixtures/subdirectory-index/e2e/earthfast.json diff --git a/cypress/fixtures/v1/e2e/armada.json b/cypress/fixtures/v1/e2e/earthfast.json similarity index 100% rename from cypress/fixtures/v1/e2e/armada.json rename to cypress/fixtures/v1/e2e/earthfast.json diff --git a/cypress/fixtures/v2/e2e/armada.json b/cypress/fixtures/v2/e2e/earthfast.json similarity index 100% rename from cypress/fixtures/v2/e2e/armada.json rename to cypress/fixtures/v2/e2e/earthfast.json diff --git a/src/service-worker/src/armada/driver.ts b/src/service-worker/src/armada/driver.ts index 6f6460c..42f8418 100644 --- a/src/service-worker/src/armada/driver.ts +++ b/src/service-worker/src/armada/driver.ts @@ -18,7 +18,8 @@ const IDLE_DELAY = 1000; const MAX_IDLE_DELAY = 5000; export class ArmadaDriver extends Driver { - public static readonly MANIFEST_FILENAME = 'armada.json'; + public static readonly MANIFEST_FILENAME = 'earthfast.json'; + public static readonly FALLBACK_MANIFEST_FILENAME = 'armada.json'; // Override the state property so we can panic if the service worker ever attempts to transition // into a non-NORMAL state. We throw an error instead of just ignoring it because such a @@ -203,22 +204,28 @@ export class ArmadaDriver extends Driver { } protected async fetchLatestManifestOnce(node: string): Promise { - let resp: Response; - try { - resp = await this.apiClient.getContent(ArmadaDriver.MANIFEST_FILENAME, node); - } catch (err) { - const msg = `Error fetching manifest: node=${node} error=${err}`; - await this.broadcast(MsgManifestFetchError(msg)); - throw err; - } + const filenames = [ArmadaDriver.MANIFEST_FILENAME, ArmadaDriver.FALLBACK_MANIFEST_FILENAME]; + for (const filename of filenames) { + try { + const resp = await this.apiClient.getContent(filename, node); - if (!resp.ok) { - const msg = `Error fetching manifest: node=${node} status=${resp.status}`; - await this.broadcast(MsgManifestFetchError(msg)); - throw new SwManifestFetchFailureError(msg); + if (resp.ok) { + return resp.text(); + } + + if (filename === filenames[filenames.length - 1]) { + throw new Error(`HTTP error: ${resp.status}`); + } + } catch (err) { + if (filename === filenames[filenames.length - 1]) { + const msg = `Error fetching manifest: node=${node} error=${err}`; + await this.broadcast(MsgManifestFetchError(msg)); + throw new SwManifestFetchFailureError(msg); + } + } } - return resp.text(); + throw new Error('Unexpected error in fetchLatestManifestOnce'); } protected async probeLatestManifest(): Promise {