Skip to content

Conversation

@pdesoyres-cc
Copy link
Contributor

@pdesoyres-cc pdesoyres-cc commented Sep 3, 2025

What this PR do?

This PR adds support for SSE:

  • in the mock-api test tool
  • in the base client framework
  • implement all logs command

How to review

  • check the commit
  • try stream commands

@pdesoyres-cc pdesoyres-cc changed the title Feat/sse sse: add support of SSE on new clever client Sep 3, 2025
@pdesoyres-cc pdesoyres-cc marked this pull request as ready for review September 12, 2025 14:50
@pdesoyres-cc pdesoyres-cc self-assigned this Sep 12, 2025
@pdesoyres-cc pdesoyres-cc force-pushed the feat/sse branch 3 times, most recently from 7aaaa0b to 1dbd4d6 Compare September 16, 2025 13:14
@pdesoyres-cc pdesoyres-cc requested review from florian-sanders-cc and removed request for FlorentinDUBOIS September 19, 2025 07:34
Copy link
Contributor

@florian-sanders-cc florian-sanders-cc left a comment

Choose a reason for hiding this comment

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

I've tested with the examples provided in the docs and it works great 😎
It's very easy to set up and use so really great job 🙌

Didn't see any issue with the docs or the code but I just discovered the subject today so 🤷

@florian-sanders-cc
Copy link
Contributor

Ah well, I just remembered: not related to this PR but we could add the cors: true to the examples now that it's false by default, WDYT @pdesoyres-cc?

Copy link
Member

@hsablonniere hsablonniere left a comment

Choose a reason for hiding this comment

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

👏 Impressive work @pdesoyres-cc, well done !!

👍 I had to ask Claude some help for the review but the fact that he was able to understand your code really well was a good sign !!

I create a few comments and here are some more general notes:

  • I had no autocomplete available for StreamApplicationRuntimeLogCommand and other commands, I'm not sure why
  • We may investigate memory leaks with listeners and signals in the future, I'm not sure we really have a problem
    • Maybe we could remove all listeners when .close() is called
  • Currently, we only retry on 5xx errors - we could we also retry on 408 (Request Timeout)
    or 429 (Too Many Requests)?
  • What happens if resume() is called while in connecting state?
  • The debugging is done with console.log, no way to plug a logger, maybe for later...
  • Would it be acceptable to use AbortSignal.any() instead of the custom combine
    function?

@pdesoyres-cc
Copy link
Contributor Author

I had no autocomplete available for StreamApplicationRuntimeLogCommand and other commands, I'm not sure why

I'm not sure to understand your problem. I tried, and I have the same behavior than when using client.send().

  • We may investigate memory leaks with listeners and signals in the future, I'm not sure we really have a problem. Maybe we could remove all listeners when .close() is called
  • Currently, we only retry on 5xx errors - we could we also retry on 408 (Request Timeout) or 429 (Too Many Requests)?
  • What happens if resume() is called while in connecting state?

Note that the implementation of cc-stream.js is a rewrite of the old clever-cloud-sse.js. I decided to only rework the shape of the class, and keep the logic as is.

Clearly, there are way for improvements.

  • CcStream instance is a one use purpose: you should not be able to use start() after streaming ended.
  • Like you said, resume() should do nothing if stream state is not paused.
  • You're right, we should remove listeners when .close is called.

The debugging is done with console.log, no way to plug a logger, maybe for later...

Yes, maybe later.

Would it be acceptable to use AbortSignal.any() instead of the custom combine function?

AbortSignal.any() is newly available. So we need to wait a little bit

@pdesoyres-cc pdesoyres-cc merged commit bdfb45b into master Nov 14, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants