Title: v7.80.0 breaks tRPC middleware handler (Typescript) · Issue #9536 · getsentry/sentry-javascript · GitHub
Open Graph Title: v7.80.0 breaks tRPC middleware handler (Typescript) · Issue #9536 · getsentry/sentry-javascript
X Title: v7.80.0 breaks tRPC middleware handler (Typescript) · Issue #9536 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/9536
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"v7.80.0 breaks tRPC middleware handler (Typescript)","articleBody":"### Is there an existing issue for this?\n\n- [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\n- [X] I have reviewed the documentation https://docs.sentry.io/\n- [X] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\n\n### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Which SDK are you using?\n\n@sentry/node\n\n### SDK Version\n\n7.80.0\n\n### Framework Version\n\n_No response_\n\n### Link to Sentry event\n\n_No response_\n\n### SDK Setup\n\nThe following downgrade of all dependencies worked, the combination of all latest doesnt:\r\n\r\n```diff\r\n \"@sentry/esbuild-plugin\": \"^2.10.0\",\r\n- \"@sentry/node\": \"^7.80.0\",\r\n- \"@sentry/serverless\": \"^7.80.0\",\r\n+ \"@sentry/node\": \"^7.79.0\",\r\n+ \"@sentry/serverless\": \"^7.79.0\",\r\n- \"@trpc/server\": \"^10.43.3\",\r\n+ \"@trpc/server\": \"^10.43.2\",\r\n```\r\n\r\nHere is my trpc setup:\r\n\r\n```ts\r\nimport { Handlers } from '@sentry/node';\r\nimport { TRPCError, initTRPC } from '@trpc/server';\r\nimport superjson from 'superjson';\r\n\r\nimport { type Context } from './context';\r\n\r\nexport const t = initTRPC\r\n .context\u003cContext>()\r\n .create({\r\n transformer: superjson,\r\n });\r\n\r\nexport const middleware = t.middleware;\r\nexport const router = t.router;\r\n\r\nconst sentryMiddleware = middleware(\r\n // 1.\r\n Handlers.trpcMiddleware({\r\n attachRpcInput: false,\r\n }),\r\n);\r\n\r\nconst isAuthenticated = middleware(({ next, ctx }) => {\r\n if (ctx.user === null) {\r\n throw new TRPCError({\r\n code: 'UNAUTHORIZED',\r\n message: 'Unauthorized',\r\n });\r\n }\r\n\r\n return next({\r\n ctx: {\r\n ...ctx,\r\n user: ctx.user,\r\n },\r\n });\r\n});\r\n\r\nexport const publicProcedure = t.procedure.use(sentryMiddleware);\r\nexport const protectedProcedure = t.procedure.use(sentryMiddleware).use(isAuthenticated); // 2.\r\n```\r\n\r\nDepending on which combination of versions i tried, no. 1 had a type error (the middleware is now async), or no. 2 had the wrong context. Swapping the Auth middleware with Sentry had a similar result (type errors)\n\n### Steps to Reproduce\n\n1. Create a tRPC server with latest sentry integration\r\n2. Try to compile with typescript\n\n### Expected Result\n\nNo Type errors, project compiles\n\n### Actual Result\n\n```\r\nError: ../server/src/trpc.ts(17,3): error TS[23](https://github.com/spaceemotion/novelcrafter/actions/runs/6843475593/job/18606103847#step:11:24)45: Argument of type '\u003cT>({ path, type, next, rawInput }: TrpcMiddlewareArguments\u003cT>) => Promise\u003cT>' is not assignable to parameter of type 'MiddlewareFunction\u003c{ _config: RootConfig\u003c{ ctx: { user: { id: string; } | null; req: FastifyRequest\u003cRouteGenericInterface, RawServerDefault, IncomingMessage, FastifySchema, FastifyTypeProviderDefault, unknown, FastifyBaseLogger, ResolveFastifyRequestType\u003c...>>; res: FastifyReply\u003c...>; }; meta: object; errorShape: De...'.\r\n Type 'Promise\u003cPromise\u003cMiddlewareResult\u003c{ _config: RootConfig\u003c{ ctx: { user: { id: string; } | null; req: FastifyRequest\u003cRouteGenericInterface, RawServerDefault, IncomingMessage, ... 4 more ..., ResolveFastifyRequestType\u003c...>>; res: FastifyReply\u003c...>; }; meta: object; errorShape: DefaultErrorShape; transformer: typeof Supe...' is not assignable to type 'Promise\u003cMiddlewareResult\u003cProcedureParams\u003cAnyRootConfig, unknown, unknown, unknown, unknown, unknown, unknown>>>'.\r\n Type 'Promise\u003cMiddlewareResult\u003c{ _config: RootConfig\u003c{ ctx: { user: { id: string; } | null; req: FastifyRequest\u003cRouteGenericInterface, RawServerDefault, IncomingMessage, ... 4 more ..., ResolveFastifyRequestType\u003c...>>; res: FastifyReply\u003c...>; }; meta: object; errorShape: DefaultErrorShape; transformer: typeof SuperJSON; }...' is not assignable to type 'MiddlewareResult\u003cProcedureParams\u003cAnyRootConfig, unknown, unknown, unknown, unknown, unknown, unknown>>'.\r\nError: ../server/src/trpc.ts(39,73): error TS2345: Argument of type 'MiddlewareBuilder\u003c{ _config: RootConfig\u003c{ ctx: { user: { id: string; } | null; req: FastifyRequest\u003cRouteGenericInterface, RawServerDefault, IncomingMessage, FastifySchema, FastifyTypeProviderDefault, unknown, FastifyBaseLogger, ResolveFastifyRequestType\u003c...>>; res: FastifyReply\u003c...>; }; meta: object; errorShape: Def...' is not assignable to parameter of type 'MiddlewareBuilder\u003c{ _config: RootConfig\u003c{ ctx: { user: { id: string; } | null; req: FastifyRequest\u003cRouteGenericInterface, RawServerDefault, IncomingMessage, ... 4 more ..., ResolveFastifyRequestType\u003c...>>; res: FastifyReply\u003c...>; }; meta: object; errorShape: DefaultErrorShape; transformer: typeof SuperJSON; }>; ... ...'.\r\n Type 'import(\"/home/runner/work/novelcrafter/novelcrafter/application/node_modules/.pnpm/@trpc+server@10.43.3/node_modules/@trpc/server/dist/core/middleware\").MiddlewareBuilder\u003c{ _config: import(\"/home/runner/work/novelcrafter/novelcrafter/application/node_modules/.pnpm/@trpc+server@10.43.3/node_modules/@trpc/server/dist/...' is not assignable to type 'import(\"/home/runner/work/novelcrafter/novelcrafter/application/node_modules/.pnpm/@trpc+server@10.43.3/node_modules/@trpc/server/dist/core/middleware\").MiddlewareBuilder\u003c{ _config: import(\"/home/runner/work/novelcrafter/novelcrafter/application/node_modules/.pnpm/@trpc+server@10.43.3/node_modules/@trpc/server/dist/...'. Two different types with this name exist, but they are unrelated.\r\n The types of 'unstable_pipe(...)._middlewares' are incompatible between these types.\r\n Type 'import(\"/home/runner/work/novelcrafter/novelcrafter/application/node_modules/.pnpm/@trpc+server@10.43.3/node_modules/@trpc/server/dist/core/middleware\").MiddlewareFunction\u003c{ _config: import(\"/home/runner/work/novelcrafter/novelcrafter/application/node_modules/.pnpm/@trpc+server@10.43.3/node_modules/@trpc/server/dist...' is not assignable to type 'import(\"/home/runner/work/novelcrafter/novelcrafter/application/node_modules/.pnpm/@trpc+server@10.43.3/node_modules/@trpc/server/dist/core/middleware\").MiddlewareFunction\u003c{ _config: import(\"/home/runner/work/novelcrafter/novelcrafter/application/node_modules/.pnpm/@trpc+server@10.43.3/node_modules/@trpc/server/dist...'. Two different types with this name exist, but they are unrelated.\r\n Type 'import(\"/home/runner/work/novelcrafter/novelcrafter/application/node_modules/.pnpm/@trpc+server@10.43.3/node_modules/@trpc/server/dist/core/middleware\").MiddlewareFunction\u003c{ _config: import(\"/home/runner/work/novelcrafter/novelcrafter/application/node_modules/.pnpm/@trpc+server@10.43.3/node_modules/@trpc/server/dist...' is not assignable to type 'import(\"/home/runner/work/novelcrafter/novelcrafter/application/node_modules/.pnpm/@trpc+server@10.43.3/node_modules/@trpc/server/dist/core/middleware\").MiddlewareFunction\u003c{ _config: import(\"/home/runner/work/novelcrafter/novelcrafter/application/node_modules/.pnpm/@trpc+server@10.43.3/node_modules/@trpc/server/dist...'. Two different types with this name exist, but they are unrelated.\r\n Types of parameters 'opts' and 'opts' are incompatible.\r\n Type '{ ctx: {}; type: \"query\" | \"mutation\" | \"subscription\"; path: string; input: unique symbol; rawInput: unknown; meta: object | undefined; next: { (): Promise\u003cMiddlewareResult\u003c{ _config: RootConfig\u003c{ ctx: { user: { id: string; } | null; req: FastifyRequest\u003c...>; res: FastifyReply\u003c...>; }; meta: object; errorShape: Def...' is not assignable to type '{ ctx: { user: { id: string; } | null; req: FastifyRequest\u003cRouteGenericInterface, RawServerDefault, IncomingMessage, FastifySchema, FastifyTypeProviderDefault, unknown, FastifyBaseLogger, ResolveFastifyRequestType\u003c...>>; res: FastifyReply\u003c...>; }; ... 5 more ...; next: { ...; }; }'.\r\n Types of property 'ctx' are incompatible.\r\n Type '{}' is missing the following properties from type '{ user: { id: string; } | null; req: FastifyRequest\u003cRouteGenericInterface, RawServerDefault, IncomingMessage, FastifySchema, FastifyTypeProviderDefault, unknown, FastifyBaseLogger, ResolveFastifyRequestType\u003c...>>; res: FastifyReply\u003c...>; }': user, req, res\r\n```","author":{"url":"https://github.com/spaceemotion","@type":"Person","name":"spaceemotion"},"datePublished":"2023-11-12T23:04:04Z","url":"https://github.com/getsentry/sentry-javascript/issues/9536"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b8162e8f-92d2-49da-d077-d8c886574c8e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E0B4:8F74F:5F0A3D:8549BB:6B0449C9 |
| html-safe-nonce | e92a8b969253c2b06bdbcb54804a5ff3877345abfa34a5fb24e03eda4ab8bf19 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMEI0OjhGNzRGOjVGMEEzRDo4NTQ5QkI6NkIwNDQ5QzkiLCJ2aXNpdG9yX2lkIjoiNDM1MzU0MTYyNzk4NjU5NDI0OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 528ba10c7b853b15ad1ad5bdcd46486dc07e4dc888a242907d3d6bbdd877e9d6 |
| hovercard-subject-tag | issue:1989624615 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/9536/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d8d84daf1264949c990d7516241b24758c93cdb1a4e653a9d7d1faa96395b1e1/getsentry/sentry-javascript/issues/9536 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d8d84daf1264949c990d7516241b24758c93cdb1a4e653a9d7d1faa96395b1e1/getsentry/sentry-javascript/issues/9536 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | spaceemotion |
| hostname | github.com |
| expected-hostname | github.com |
| None | d4495c3631faba668036f176d1f5946901c5172efd73a6edb984029e7d4f8e46 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9ac4337fb7c6a5846cdfdb1a04f154d3c33ebc77 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width