Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abort content replace if error happens on model loading #847

Open
mydea opened this issue Aug 19, 2021 · 0 comments
Open

Abort content replace if error happens on model loading #847

mydea opened this issue Aug 19, 2021 · 0 comments

Comments

@mydea
Copy link

mydea commented Aug 19, 2021

We use fastboot for a content-focused website which is powered by a wordpress instance. Whenever content is changed we run a static build with prember & deploy the application - all good so far.

Now I noticed that if wordpress goes down (for whatever reason), and somebody visits a page, the pre-rendered page will be shown correctly, but once ember is loaded & it tries to hit the API and fails, it replaces the body with the error message.

Is there a way to basically say:

"If one of these errors is encountered, skip doing anything and just leave the HTML as it is"? Because it would be much better to just show the static page in such a scenario.

I hope I could explain my question properly 😅

I am using EXPERIMENTAL_RENDER_MODE_SERIALIZE=true, if that is relevant.

One "solution" I could think of is to return a never-resolving promise from the model hook in such a case instead of throwing an error, as I've observed that while the model hooks are pending it will not replace the content. Would that be a "good" solution or is there a better way to do this? E.g. something like that feels rather hacky:

export default class PageRoute extends Route {
  @service fastboot;

  async model(params) {
    try {
      return await this.store.findRecord('page', params.id);
    } catch(error) {
      if (!this.fastboot.isFastBoot) {
        await new Promise();
      }
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant