Skip to content

feature: Load workspace build logs from streaming #1997

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

Merged
merged 10 commits into from
Jun 3, 2022
Prev Previous commit
Next Next commit
Fix lint
  • Loading branch information
BrunoQuaresma committed Jun 2, 2022
commit 7232e6548fec797b93a6988b1e11cf4bebc1dd15
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const workspaceBuildMachine = createMachine(
const reader = await API.streamWorkspaceBuildLogs(ctx.buildId)

// Watching for the stream
// eslint-disable-next-line no-constant-condition
// eslint-disable-next-line no-constant-condition, @typescript-eslint/no-unnecessary-condition
while (true) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to worry about error handling or cleanup if done never returns?

Copy link
Collaborator Author

@BrunoQuaresma BrunoQuaresma Jun 3, 2022

Choose a reason for hiding this comment

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

It is a good point. I think for now we can rely on done being always called, why:

  • We are using a polyfill(https://canjs.com/doc/can-ndjson-stream.html) because Firefox does not support some stream APIs
  • I took a look and I didn't find anything related to "read failure" or something related
  • If an error is thrown, it will stop the execution anyway
  • This error, in particular, looks tricky to handle so I would expect someone having issues with that to think of a proper solution
  • In summary, I don't know how to do that and it looks complex to handle 😆, so I would not invest too much time on that right now, but if you have an idea how to solve that, I would love to learn and implement it for sure.

Copy link
Member

Choose a reason for hiding this comment

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

Ha! Thanks for the breakdown - what you said makes sense and I think you're right to hold off. If this becomes an issue in the future, we can look into calling cancel on the ReadableStream object.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ahh, nice!

const { value, done } = await reader.read()

Expand Down