Skip to content

Add transform function support to sync and sync_render - #99

Merged
magnetised merged 10 commits into
mainfrom
53-allow-for-transformation-of-messages-from-the-upstream-server-before-passing-to-clients
Sep 8, 2025
Merged

Add transform function support to sync and sync_render#99
magnetised merged 10 commits into
mainfrom
53-allow-for-transformation-of-messages-from-the-upstream-server-before-passing-to-clients

Conversation

@magnetised

Copy link
Copy Markdown
Contributor

Fixes #53

@magnetised
magnetised force-pushed the 53-allow-for-transformation-of-messages-from-the-upstream-server-before-passing-to-clients branch from cc47e8e to b79d372 Compare September 2, 2025 12:59
@magnetised
magnetised requested a review from thruflo September 4, 2025 09:45
@magnetised
magnetised force-pushed the 53-allow-for-transformation-of-messages-from-the-upstream-server-before-passing-to-clients branch 2 times, most recently from 8555ea1 to 9899e63 Compare September 4, 2025 14:28
@evanob

evanob commented Sep 4, 2025

Copy link
Copy Markdown

@magnetised I tried this myself and it works really nicely!

The only problem is when the payload starts to get large, in which case I start to get errors like (Jason.DecodeError) unexpected end of input at position 157004 coming from Phoenix.Sync.Electric.map_response_body/2. My best guess is that this is caused by incomplete JSON when the response is chunked 😬

@thruflo thruflo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great stuff 👍

Comment thread apps/plug_sync/README.md Outdated
Comment thread lib/phoenix/sync.ex Outdated
Comment thread lib/phoenix/sync.ex Outdated
@magnetised

Copy link
Copy Markdown
Contributor Author

@magnetised I tried this myself and it works really nicely!

The only problem is when the payload starts to get large, in which case I start to get errors like (Jason.DecodeError) unexpected end of input at position 157004 coming from Phoenix.Sync.Electric.map_response_body/2. My best guess is that this is caused by incomplete JSON when the response is chunked 😬

That's not good... Will see if I can reproduce & fix. Thanks!

@magnetised
magnetised force-pushed the 53-allow-for-transformation-of-messages-from-the-upstream-server-before-passing-to-clients branch from 9899e63 to 35b6353 Compare September 8, 2025 10:59
@magnetised

Copy link
Copy Markdown
Contributor Author

My best guess is that this is caused by incomplete JSON when the response is chunked 😬

@evanob actually caused by my dumb implementation of the stream mapping... Fixed, thanks

@magnetised
magnetised merged commit 867ca80 into main Sep 8, 2025
5 checks passed
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.

Allow for transformation of messages from the upstream server before passing to clients

3 participants