Skip to content

SSE: Spec Interpretation Issue (preserve leading spaces) #3479

@sashirestela

Description

@sashirestela

Hi @jknack. First of all, very thanks for your fantastic web framework!

I've started to use this framework as the backend for an AI project using RAG and LLM and I'm using the SSE functionality. On the other hand, I'm using the sse.js library to handle SSE for the frontend.

What I see here is a different interpretation for the SSE Spec which is impacting in my project.

In the following SSE Spec Html Spec - Server sent events - Interpreting an event stream you can read:

image

So, sse.js and similar libraries are expecting a space after the colon and they are discarding it. Even LLMs as OpenAI are producing SSE with that extra space after the colon.

However, Jooby is processing SSE without that extra space, so, if for example streaming data arriving from the LLM starts with spaces, they are removed by sse.js, due to its SSE Spec interpretation, and we have:

Jooby sse.js
'one' 'one'
' juicy ' 'juicy '
'red' 'red'
' apple.' 'apple.'

I'm concatenating the data chunks to be shown in the UI, so the expected value is:

one juicy red apple.

but, due to the sse.js processing, currently I'm getting:

onejuicy redapple.

Can you see the issue here? Could you elaborate a change here, please?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions