Open sgrund14 opened 1 year ago
Dataloader doesn't use process.nextTick
already if not available;
https://github.com/graphql/dataloader/blob/d336bd15282664e0be4b4a657cb796f09bafbc6b/src/index.js#L240
I think Next.js checks the code and throws an error even if it is not called. I think it needs to be fixed on Next.js side.
hm, not possible to fix here? I only ask because while you have responded right away (thanks!), the vercel team hasn't taken a look at that issue for 5 months :(
wonder how they are actually determining that the code is getting run when it's not 🤔 like why does it work when the batchScheduleFn
is passed in?
Hmm you are right. I missed that. Maybe they throw this error when you try to acces the global "process" variable.
yea, seems like that could be the case. how to avoid even accessing the process
variable tho... would dataloader have to somehow check what environment it's in? or do a typeof process !== 'undefined'
check?
What problem are you trying to solve?
support the vercel edge runtime for dataloaders without workaround. see discussion here https://github.com/vercel/next.js/issues/44711 (edge does not support
process.nextTick
, which is being checked in theDataloader
package)right now, you have to pass in the
batchScheduleFn
with a setTimeout to the DataLoader to make the package work on the edge runtime like sobut this might not be ideal? not totally sure what happens in this case, I would just worry about adding latency or breaking the batching with the setTimeout instead of relying on the default behavior (batching per execution context)
Describe the solution you'd like
Dataloader should work in the edge runtime without having to pass in a
setTimeout
Describe alternatives you've considered
using the setTimeout workaround
Additional context
nice to support edge functions so that you can have zero cold start graphql functions in a serverless environment