-
-
Notifications
You must be signed in to change notification settings - Fork 275
fix: return complete sse event in async iterator (#2641) #3018
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
base: main
Are you sure you want to change the base?
fix: return complete sse event in async iterator (#2641) #3018
Conversation
|
|
🦋 Changeset detectedLatest commit: c3aba80 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@Theo-Steiner is attempting to deploy a commit to the Hey API Team on Vercel. A member of the Team first needs to authorize it. |
|
@Theo-Steiner run |
|
@mrlubos thank you for your quick reply! // ASIS
export const { stream } = getSse();
for await (const result of stream) {
// `result` is typed as `GetSseResponses`, but the actual result is `GetSseResponses['data']`
console.log(result.event) // event will always be undefined, since we are passed only the data
}
// TOBE
for await (const result of stream) {
// `result` is still typed as `GetSseResponses`, however the actual result is now the complete event (not just it's data property)
console.log(result.event) // logs the actual event
}As you can see, there is currently a bug in the SSE implementation, where the
|
|
I've updated the tests, which sadly bloats the diff of this PR by quite a bit 😅 |
|
❤️ I'm so looking forward to this. Thanks! |
Closes #2641
Background
The individual results yielded by the async iterator for the SSE client are just the
datapart of the server sent events.The type however, suggests that it should be the full event.
Description
This PR changes the returned value to be the full event, including
id,event,data&retry.Sinceretryis not part of the actual event, it is not included.Notes
The SDK snapshot tests started failing because they expected the previous function implementation.
Should I update them manually to reflect the new function body or is there a way to regenerate them automatically?