Skip to content

feat: streaming - #67

Open
ChildishForces wants to merge 5 commits into
Valerioageno:mainfrom
ChildishForces:feat/streaming
Open

feat: streaming#67
ChildishForces wants to merge 5 commits into
Valerioageno:mainfrom
ChildishForces:feat/streaming

Conversation

@ChildishForces

Copy link
Copy Markdown

No description provided.

@Valerioageno Valerioageno left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Summarizing here few comments:

  • Please reduce/remove the inline comments. I think the repo should not act as documentation except for the /// docgen comments. The function name/types should be clear enough. I generally consider them AI slop that decrase the code readability rather than improving it.
  • Fix clippy and fmt
  • The crate API should be smaller and more straightforward. Implementing usage level functions within the crate is not consistent with the philosopy of this crate. I think we should keep the StreamSink trait and a struct method for calling the streaming fn but the rest of the implementation should live outside.

Feel free to clone this repo in ossido if you think my comments are not helpful for it.

Comment thread src/ssr.rs
InvalidJs(&'static str),
FailedToParseJs(&'static str),
FailedJsExecution(&'static str),
/// A rendered promise rejected (or the function threw). Carries the

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

No need for comment here.

Comment thread src/ssr.rs
Err(err) => return Err(err),
// Replaces a `Some(props).iter()...collect()` that iterated the
// `Option`, not the array, so it only ever registered the first
// property - fine when there's one export, wrong once `render` looks

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

No need for this comment

Comment thread src/ssr.rs
/// lends for the duration of a streaming render (null at all other times). This
/// is how the bare V8 writer callback — which takes no captures — reaches the
/// caller's borrowed sink without any thread-local or `'static` state.
const SINK_SLOT: u32 = 0;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This memory allocation seems a thread_local! escape hatch. I think a correct API would be something like:

Ssr::from().render_streaming("renderStream", "__ssr_write", None, &mut |chunk: &str| print!("{chunk}"))?;

SinkGuard and Streaming structs should not be part of this crate by keeping the interaction layer thinner.

Comment thread src/ssr.rs
// the one still present here. If the slot no longer holds our pointer a
// guard failed to restore and the raw-pointer bridge is no longer sound
// - catch that in debug builds rather than read a stale pointer later.
debug_assert_eq!(

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Is this a leftover, or is it meant to stay? I think debug is not needed in this crate outside development

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants