Read the statement by Michael Teeuw here.
MMM-MealieMenu Fetch Error
-
@WallysWellies ok… I’ll watch it running here at 15 min updates…
well, I found it…
in the node helper he sets a flag, to say request is active
if the flag is set when the request comes from the module side
he just returns… does nothing.on error he does not clear the flag
(bad network, host, authorization… places where there is no recovery
those make sense…).catch((error) => { //<--- had and error here ... this.sendSocketNotification("MEALIE_ERROR", { error: "FETCH_ERROR", details: error, identifier: config.identifier }); }) .finally(() => { this.outstandingRequest = false; // < --- only clears flag on success });
one could examine the error and reset if its a potentially recoverable error…
-
@WallysWellies actually, the unrecoverable config errors are handled in a different place…
so, just copy that one line before the sendSocketNotification for error
-
@sdetweil Thank you for your advice and apologies for the delayed response - I need to enable email notifications or something…
I will try your suggestion. Much appreciated.
-
@sdetweil I’m looking at the node_helper.js file and reading your comments and I’m a little unsure what you are suggesting.
Are you saying I could edit this code block:
.catch((error) => { this.sendSocketNotification("MEALIE_ERROR", { error: "FETCH_ERROR", details: error, identifier: config.identifier }); })
to this:
.catch((error) => { this.outstandingRequest = false; this.sendSocketNotification("MEALIE_ERROR", { error: "FETCH_ERROR", details: error, identifier: config.identifier }); })
?
Sorry, I can fumble my way around code but I’m far from a programmer!
-
@WallysWellies yes, correct
-
@sdetweil Done!
I shall try and remember to report back if it seems to have worked - if I do not then we can assume I am a happy customer.
Cheers for your time.
-
-
@WallysWellies remember that this is not an official change, so it could be lost.if you refresh the module
-
@sdetweil said in MMM-MealieMenu Fetch Error:
@WallysWellies I am a mealie user too.
code looks good. will have to setup and test.
it does get the data frequently
60 seconds by default…I should probably set the default to something higher. I had it set to 60 seconds while I was developing it.
@sdetweil said in MMM-MealieMenu Fetch Error:
@WallysWellies ok… I’ll watch it running here at 15 min updates…
well, I found it…
in the node helper he sets a flag, to say request is active
if the flag is set when the request comes from the module side
he just returns… does nothing.on error he does not clear the flag
(bad network, host, authorization… places where there is no recovery
those make sense…).catch((error) => { //<--- had and error here ... this.sendSocketNotification("MEALIE_ERROR", { error: "FETCH_ERROR", details: error, identifier: config.identifier }); }) .finally(() => { this.outstandingRequest = false; // < --- only clears flag on success });
one could examine the error and reset if its a potentially recoverable error…
I thought
finally()
runs even after acatch()
, dangit.@WallysWellies said in MMM-MealieMenu Fetch Error:
@sdetweil I’m looking at the node_helper.js file and reading your comments and I’m a little unsure what you are suggesting.
Are you saying I could edit this code block:
.catch((error) => { this.sendSocketNotification("MEALIE_ERROR", { error: "FETCH_ERROR", details: error, identifier: config.identifier }); })
to this:
.catch((error) => { this.outstandingRequest = false; this.sendSocketNotification("MEALIE_ERROR", { error: "FETCH_ERROR", details: error, identifier: config.identifier }); })
?
Sorry, I can fumble my way around code but I’m far from a programmer!
I will get this fix added and set the default
updateInterval
to something a bit more sane soon. Thanks to all for troubleshooting! -
@zanix Thanks for your input :)
I made the change after posting and it certainly doesn’t break anything but I have been playing with some other modules too so have restarted the software several times meaning I haven’t given it a chance to error but based on my understanding it probably shouldn’t anymore. I don’t know why it was in the first place though - the Mealie container is on the Pi so it’s using localhost to retrieve data. Who knows.
I did make one other change because I wanted to see the next week of meals, rather than the remaining meals this week. So I changed this line:
const startOfWeek = this.getFirstDayOfWeek(config.weekStartsOnMonday);
to this:
const startOfWeek = moment();
It’s pretty crude but if you’re taking suggestions it might be nice to have the option to show x number of days in the future rather than until the end of the week. I don’t believe that’s currently possible natively?
Thanks for the module though, it’s great!
-
@WallysWellies said in MMM-MealieMenu Fetch Error:
@zanix Thanks for your input :)
I made the change after posting and it certainly doesn’t break anything but I have been playing with some other modules too so have restarted the software several times meaning I haven’t given it a chance to error but based on my understanding it probably shouldn’t anymore. I don’t know why it was in the first place though - the Mealie container is on the Pi so it’s using localhost to retrieve data. Who knows.
Hopefully that fixes the issue, let me know otherwise.
I did make one other change because I wanted to see the next week of meals, rather than the remaining meals this week. So I changed this line:
const startOfWeek = this.getFirstDayOfWeek(config.weekStartsOnMonday);
to this:
const startOfWeek = moment();
It’s pretty crude but if you’re taking suggestions it might be nice to have the option to show x number of days in the future rather than until the end of the week. I don’t believe that’s currently possible natively?
Before now no, but I did just add the fetch fix, updateInterval default to 1 hour, and some additional meal entry options in version 1.5.0.
The options are:
- currentWeek: Only show meals for the current week.
- dayLimit: How many days will be displayed after today.
- entryLimit: How many entries from future days should be shown in total.
Now you can just set
currentWeek
to false to get the same effect.Thanks for the module though, it’s great!
I appreciate that, glad it’s useful!