Closed jaked closed 1 week ago
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.
Hi @jaked, thanks for opening this report and apologies for the delay. I agree with your analysis and proposed remedy and I opened https://github.com/Azure/azure-sdk-for-js/pull/30707. I'll let you know once we make a release. Again, thanks for your patience!
@jaked @azure/core-sse@2.1.3 has been released! Please let us know if you have any other questions!
Hi @jaked. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation.
Hi @jaked, since you haven’t asked that we /unresolve
the issue, we’ll close this out. If you believe further discussion is needed, please add a comment /unresolve
to reopen the issue.
thanks! I haven't had a chance to verify the fix but the change looks good to me.
Describe the bug Returning from an iteration over an
EventMessageStream
crashes if the entire stream has already been consumed.To Reproduce Steps to reproduce the behavior:
createSseStream
(e.g. from an@azure-rest/ai-inference
response body)for await (const event of stream)
)return
from the iterator when complete (e.g. withif (event.data === "[DONE]") return
)Expected behavior Iteration completes normally without exception.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context The exception is coming from the
cancel
function in@azure/core-sse/utils.js
, which callsstream.socket.end()
when anEventMessageStream
iterationreturn
s in a generator function (since https://github.com/Azure/azure-sdk-for-js/pull/28111). But Node setsstream.socket
tonull
when the underlying message has been consumed (I think since https://github.com/nodejs/node/pull/38505 / https://github.com/nodejs/undici/pull/834), so the call fails.Replacing
stream.socket.end()
withstream.socket?.end()
fixes the issue for me.