Skip to content

Conversation

@lforst
Copy link
Contributor

@lforst lforst commented Nov 13, 2023

Fixes #9536

The issue was that the middleware returned a function that returned Promise<Promise<T>> instead of Promise<T>. To fix this we take care not to modify the return value at all and just return T.

We could have also casted to any I think but this is probably cleaner.

@lforst lforst requested review from AbhiPrasad, Lms24 and mydea November 13, 2023 12:02
captureError(e);
}
}
let maybePromiseResult;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not directly related and nothing to do, but I feel like we've written this or very similar code a lot of times by now, maybe we can find a way to extract this into some util function that we can reuse 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah agreed. It's like a promise aware try catch. Would definitely make sense to extract!

interface TrpcMiddlewareArguments<T> {
path: string;
type: 'query' | 'mutation' | 'subscription';
type: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we broading this on purpose here (just checking)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we are not depending on any of the direct strings here (just dumping what's in type onto the event) and I figured that if trpc adds more types we will break typing again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v7.80.0 breaks tRPC middleware handler (Typescript)

3 participants