Honestly, you really shouldn't be saving on unload. Without any more details on the app, it is hard to say the best practice, but maybe have the save action on input change/key-up or even a save button. The issue with doing it on unload is that you won't be able to catch any errors. I would recommend adding an action to your route to save your model.
actions: {
saveRecord() {
const record = get(this, 'model');
record.save().catch(function() {
// some call to handle errors
console.log('error');
record.rollbackAttributes();
}
}
}
Then pass this action down to your template/component (or wherever you are accessing it) and have it bubble up. It should be easier to debug versus trying to catch errors on unload, which is generally not great practice.
You may be able to troubleshoot the issue better this way. You may find that the issue is on the DB/API side (depending on what is serving your data). Are you able to save in other areas of your app?
If there is a specific reason why it has to happen on unload would you mind elaborating?