sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Broken custom dataloader methods

Open michalsanger opened this issue 1 year ago • 2 comments

Is there an existing issue for this?

  • [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
  • [x] I have reviewed the documentation https://docs.sentry.io/
  • [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

8.33.1

Framework Version

fastify 5.0.0

Link to Sentry event

No response

Reproduction Example/SDK Setup

No response

Steps to Reproduce

The automated dataloader integration added in https://github.com/getsentry/sentry-javascript/pull/13664 breaks my code.

I have a dataloader like this:

export class ProductDataloader extends DataLoader {
    constructor() {
        super(async (globalIds: ReadonlyArray<string>) => {
            return batchFn(globalIds);
        });
    }

    public async loadByInternalId(id: number) {
        const globalId = toGlobalId('Product', id);
        return this.load(globalId);
    }
}

Expected Result

That code worked OK until "@sentry/node": "8.30.0"

Actual Result

After upgrade to "@sentry/node": "8.31.0" or later, calling loadByInternalId method fails:

context.dataloaders.product.loadByInternalId is not a function

michalsanger avatar Oct 04 '24 14:10 michalsanger

Hey @michalsanger sorry for the trouble here! For now you can disable the dataloader integration like so:

Sentry.init({
  // ...
  integrations: function (integrations) {
    // filter out Dataloader integration due to bug
    return integrations.filter(function (integration) {
      return integration.name !== "Dataloader";
    });
  },
});

docs: https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/#removing-a-default-integration

@onurtemizkan could you help investigate why this is happening?

AbhiPrasad avatar Oct 04 '24 15:10 AbhiPrasad

@AbhiPrasad thanks for the workaround, works OK.

michalsanger avatar Oct 04 '24 17:10 michalsanger

Opened a PR upstream to fix this: https://github.com/open-telemetry/opentelemetry-js-contrib/pull/2498

onurtemizkan avatar Oct 23 '24 17:10 onurtemizkan

@onurtemizkan I guess this has since been released and should be fixed, since v10 where we are on latest of the instrumentation again?

mydea avatar Aug 11 '25 12:08 mydea

@mydea - Yes, this should be resolved

onurtemizkan avatar Aug 11 '25 12:08 onurtemizkan