Skip to content
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

Fix HTTP client reading non-ascii journal content #47

Merged
merged 4 commits into from
Aug 9, 2024

Conversation

travjenkins
Copy link
Member

@travjenkins travjenkins commented Jul 8, 2024

Issue

#46

Fixes

Updated tests to work with recent control plane changes
...tbd

Tests

Added content read tests that include Arabic in the messages. These tests are failing until we implement a fix. Also, noticed that in the printing of the snapshot the string that contains Arabic seems to get flipped. Not sure if this is Deno being clever to render RTL.

Notes

ShardClient.list task selector test is failing locally when checking for PRIMARY as the status. It is failing due to this error:
image

Switching more tests to snapshots to test a wider range of things all at once
Getting some tests updated to handle the new control plane
@travjenkins travjenkins requested a review from psFried July 19, 2024 17:42
@travjenkins travjenkins changed the title Better handling of Arabic characters Add failing test for Arabic characters Jul 22, 2024
travjenkins and others added 2 commits July 23, 2024 10:54
The grpc gateway returns journal content as a base64-encoded string.
Previously, we had been using `atob` to decode this, but that function
does not work if the decoded content contains any byte values larger
than 0x7f, because of course we can't have nice things in JS. So this
adds one of those looks-insane-but-actually-works workarounds to make
base64 decoding work properly with arbitrary utf-8 data.
@psFried psFried changed the title Add failing test for Arabic characters Fix HTTP client reading non-ascii journal content Aug 9, 2024
@@ -50,7 +50,17 @@ export function decodeContent() {
transform(value, controller) {
// Base64 decode the `content` field and send it as a chunk.
if (value.content?.length) {
controller.enqueue(atob(value.content));
// The `atob` function does not work properly if the decoded content contains any byte
Copy link
Member Author

Choose a reason for hiding this comment

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

I know we are not running in node but in the UI we have stopped using atob and btoa and replaced with 'Bufferand.toString('base64')`

https://dev.to/2ezpz2plzme/btoa-replacement-in-nodejs-3k6g

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't mind trying this out on my local and running the tests

Copy link
Member Author

Choose a reason for hiding this comment

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

Never mind - as that will be a pain polyfilling Node stuff.

@psFried psFried merged commit a906ada into main Aug 9, 2024
1 check 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.

3 participants