graph-gophers / dataloader

Implementation of Facebook's DataLoader in Golang
MIT License
1.2k stars 75 forks source link

NoCache option doesn't seems to work in v6.0.0 #96

Open zdraganov opened 1 year ago

zdraganov commented 1 year ago

Hello all,

I receive a panic when using the loader with the NoCache option. The same code works fine with InMemoryCache passed or by default.

Anyone managed to make the NoCache working in v6.0.0

ctx = context.WithValue(ctx, k, dataloader.NewBatchedLoader(helloBatchFunction, dataloader.WithCache(&dataloader.NoCache{})))

And the time I invoke the Load(ctx, key) function, I receive some internal panic in the dataloader package.

panic({0x18b7660, 0x277de20})
/usr/local/go/src/runtime/panic.go:844 +0x264
github.com/myorg/myrepo/internal/loader.(*pairsTournamentLoader).loadBatch(0x40006b3380, {0x1c5e9c8, 0x4000daed20}, {0x4000dac9c0, 0x3, 0x4})
/app/internal/loader/hello_loader.go:73 +0x600
github.com/graph-gophers/dataloader.(*batcher).batch.func1(0x4000de8df0, 0x4000daeea0, {0x1c5e9c8, 0x4000daed20}, {0x4000dac9c0, 0x3, 0x4}, 0x4000f29e80)
/go/pkg/mod/github.com/graph-gophers/dataloader@v5.0.0+incompatible/dataloader.go:432 +0xb4
github.com/graph-gophers/dataloader.(*batcher).batch(0x4000daeea0, {0x1c5e9c8, 0x4000daed20})
/go/pkg/mod/github.com/graph-gophers/dataloader@v5.0.0+incompatible/dataloader.go:433 +0x320
created by github.com/graph-gophers/dataloader.(*Loader).Load
/go/pkg/mod/github.com/graph-gophers/dataloader@v5.0.0+incompatible/dataloader.go:241 +0x568
mgreer commented 1 year ago

Having same issue

eaglemoor commented 1 year ago

Please, don't use context for storage DataLoader. It's not good way.

Can u write some example for check your problem ? Because in example https://github.com/graph-gophers/dataloader/blob/v6.0.0/example/no_cache/no_cache_test.go all work fine.

zenyui commented 1 year ago

Same issue here