ember-fastboot / ember-fastboot/ember-cli-fastboot

Abort content replace if error happens on model loading

Open
#847 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
850
Forks
161
Avg merge
17h 45m
Merged PRs (30d)
19

Description

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 :sweat_smile:

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:

```js
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();
}
}
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.