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
Support streaming inside of slots #6775
Conversation
🦋 Changeset detectedLatest commit: 4481566 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me, nice fix!
let chunk = decoder.decode(bytes); | ||
chunks.push(chunk); | ||
} | ||
expect(chunks.length).to.be.greaterThan(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is 2
the expected the number of slots in the test fixture? Is it because we render two Wait
components?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 is the expected. You get the first initial chunk. Then the chunk after the first wait. Then the chunk after the second wait. I guess I could change this to equal because it should always be 3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might help. Having a strict equal can prevent possible regressions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for avoiding it is that Node buffers writes. If you send 2 chunks with no wait it will combine them into a single write on the network. So the chunks can be less than the number you expect, but never more. In this case, the wait is sufficiently long enough that it should always split into 3 chunks. SO I've updated the test to reflect that.
Changes
Astro.slots.render('name')
API previouslyrenderSlot
returned a string. This meant no streaming of slots.renderSlotToString
. It's still used a bit internally.renderSlot
, which is now just used inside the template (for<slot></slot>
) to stream.Testing
Docs
N/A, bug fix