Closed Vadorequest closed 3 years ago
For the record, I've disabled this plugin in development mode to avoid the issue for now, but I'd be better to use it if that means fetching the API only once and no more even when changing pages. (similar to how it'd work in staging/production)
hey @Vadorequest, sorry for the radio silence in the past few days. Been rather busy starting up a new role but I'll definitely address a lot of the issues you've brought up soon (potentially today). I really do appreciate you taking the time to give this feedback!
Awesome!
For the record I've added your plugin into https://github.com/UnlyEd/next-right-now because the demo uses a lot of static pages, with a lot of static data that needs to be fetched once during build. :)
This one might be slightly difficult to address but it's definitely something I want to fix.
This is an issue I've noticed in development mode only. It seems to be invoked multiple times, probably because of how Next.js works (several workers in parallel
I think you're right and if that's the case, this may require some higher-level coordination (maybe via a webpack plugin vs a loader??). I have another next project, next-plugin-query-cache
that attempts to de-dupe requests so I may borrow some ideas from there to get this working.
I'll keep you posted :D
I believe this is the same issue as #14 (or at least the way I plan on solving it should solve both!). I'll close this in favor but please feel to reply if anything is different.
hey @Vadorequest, I just released an alpha with a mechanism that de-dupes the preval runs. I'm looking for some testers if you'd like to try it out in your projects.
If everything looks good, I can release something relatively soon.
Thanks for notifying me, I would need to run some tests, not sure when I'll have some free time for that 😬
@Vadorequest totally understand. took me a few months to find time to address this one as you can see 😅
I'd like to know if it's possible to avoid the plugin to fetch data multiple times but only once at the very beginning, when the server starts.
This is an issue I've noticed in development mode only. It seems to be invoked multiple times, probably because of how Next.js works (several workers in parallel), but this causes us to hit our API too much, which leads to being rate limited and only part of the data are available, which makes the whole app in an inconsistent state. Also, the success/failure is random (depends on I/O) and it affects (worsen) the developer experience quite a lot.
Any trick to improve this workflow?
Here's an example of the logs when loading the page once, just after starting the development server. You'll notice the
[EducationalProgramStep] 26 airtable API records fetched
is printed 11 times in total, meaning it fetches the 11 times instead of one, and it eventually crashes due to rate limits being hit.When not using this plugin, it fetches the API 2 times instead of 11.