Repository navigation
Description
Describe the feature you'd like to request
Currently lastEventId, an input schema field, is hardcoded through the project:
trpc/packages/client/src/internals/inputWithTrackedEventId.ts
Lines 11 to 14 in 1c35763
| return { | |
| ...(input ?? {}), | |
| lastEventId, | |
| }; |
This is not clear from the documentation that this name is hardcoded to have special meaning and not just a generic example.
I propose to make this a configurable setting per subscription. Examples where it makes sense:
- Most of the time, the subscriptions return objects of a particular type, and the code becomes more clear if the input field could be named
lastPostId,lastMessageId, etc. (both server and client side!) - I have a project where the entire naming is snake_case, and
lastEventIdlooks alien in the input schema.
Describe the solution you'd like to see
subscription() could have an overload accepting options, such as:
const subscribeToMessages = procedure
.input(v.object({
lastMessageId: v.optional(v.pipe(v.string(), v.uuid())),
}))
.subscription({ lastEventIdField: "lastMessageId" }, async function* ({
input: { lastMessageId },
signal,
}) {
// ImplementationDescribe alternate solutions
At the very least, it should be very clearly documented that the field must be named exactly lastEventId and this is not just an example. Currently, the documentation only mentions that "this is part of the EventSource-spec" but the said spec field is Last-Event-ID (an HTTP header), which doesn't really imply that lastEventId is also hardcoded (because unlike the standard HTTP header, there is no real reason to do so).
Additional information
No response
👨👧👦 Contributing
- 🙋♂️ Yes, I'd be down to file a PR implementing this feature!
Activity
dkrieger commentedon Oct 23, 2025
I'd like to suggest that whether or not this feature request is ultimately accepted, the docs should be updated today to clarify this situation
KATT commentedon Nov 2, 2026
🤖 In v12,
lastEventIdisn't an input field anymore: the resolver gets it as an option, so your input can use any names. https://v12.trpc.io/v12/docs/subscriptions/overview#resuming. v12 isn't released yet and there's no ETA.