Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attachRpcInput not working for trpc v11 #13795

Closed
3 tasks done
DawnMD opened this issue Sep 25, 2024 · 8 comments · Fixed by #13831
Closed
3 tasks done

attachRpcInput not working for trpc v11 #13795

DawnMD opened this issue Sep 25, 2024 · 8 comments · Fixed by #13831
Assignees
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK

Comments

@DawnMD
Copy link

DawnMD commented Sep 25, 2024

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

8.30.0

Framework Version

Next 14.2.11

Link to Sentry event

No response

Reproduction Example/SDK Setup

I have added this in tprc.ts file

const timingMiddleware = t.middleware(async ({ next, path }) => {
  const start = Date.now();

  if (t._config.isDev) {
    // artificial delay in dev
    const waitMs = Math.floor(Math.random() * 400) + 100;
    await new Promise((resolve) => setTimeout(resolve, waitMs));
  }

  const result = await next();

  const end = Date.now();
  console.log(`[TRPC] ${path} took ${end - start}ms to execute`);

  return result;
});

const sentryMiddleware = t.middleware(
  Sentry.trpcMiddleware({
    attachRpcInput: true,
  }),
);

export const publicProcedure = t.procedure
  .use(sentryMiddleware)
  .use(timingMiddleware);

Also sentry.init is as follows

// This file configures the initialization of Sentry on the client.
// The config you add here will be used whenever a users loads a page in their browser.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import * as Sentry from "@sentry/nextjs";
import { env } from "./env";

Sentry.init({
  dsn: env.NEXT_PUBLIC_SENTRY_DSN,
  environment: env.NEXT_PUBLIC_SENTRY_ENV,

  // Adjust this value in production, or use tracesSampler for greater control
  tracesSampleRate: 1,

  // Setting this option to true will print useful information to the console while you're setting up Sentry.
  debug: false,

  replaysOnErrorSampleRate: 1.0,

  // This sets the sample rate to be 10%. You may want this to be 100% while
  // in development and sample at a lower rate in production
  replaysSessionSampleRate: 0.1,

  // You can remove this option if you're not planning to use the Sentry Session Replay feature:
  integrations: [
    Sentry.replayIntegration({
      // Additional Replay configuration goes in here, for example:
      maskAllText: true,
      blockAllMedia: true,
    }),
  ],
});

Steps to Reproduce

  1. Create a new repo with t3 stack
  2. add sentry
  3. add sentry trpc middleware
  4. throw a error from mutation procedure

I can only see the error that is thrown from trpc procedure with throw new Error(.....) but the inputs are not passed to sentry!

Expected Result

I expect to see the input passed on to the mutation procedure!

Actual Result

Image

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Sep 25, 2024
@github-actions github-actions bot added the Package: nextjs Issues related to the Sentry Nextjs SDK label Sep 25, 2024
@DawnMD
Copy link
Author

DawnMD commented Sep 25, 2024

Or maybe it is sending the input but its hidden somewhere in the UI I'm not seeing! 🤔🤔

@chargome
Copy link
Member

@DawnMD thanks for reaching out – could you send me a link to a specific event? If you don't want to share it here you can send me an email to [myfirstname].[mylastname]@sentry.io or on Discord.

@DawnMD
Copy link
Author

DawnMD commented Sep 26, 2024

@chargome Discord would be nice actually. Can I get your ID?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Sep 26, 2024
@chargome
Copy link
Member

@DawnMD https://discord.com/invite/sentry my id is chargome_

@DawnMD
Copy link
Author

DawnMD commented Sep 26, 2024

@DawnMD https://discord.com/invite/sentry my id is chargome_

DM'd you with the issue link from sentry!

@chargome
Copy link
Member

chargome commented Oct 1, 2024

Follow up: this was due to a change in the trpc middleware in v11 – the fix will be released soon.

Copy link
Contributor

github-actions bot commented Oct 2, 2024

A PR closing this issue has just been released 🚀

This issue was referenced by PR #13831, which was included in the 8.33.0 release.

@JoeKarow
Copy link

JoeKarow commented Oct 2, 2024

The PR associated with this issue (#13831) may have introduced type errors for tRPC v10. When upgrading Sentry from v8.32.0 to v8.33.0, I get this TypeScript error when initializing the tRPC middleware:
Image

It looks like this may be the culprit, causing a double wrapped promise for tRPC v10.

return async function <T>(opts: SentryTrpcMiddlewareArguments<T>): Promise<T> {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants