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

Bug: Unexpected characters appear in the Chinese encoding during streaming #30453

Closed
shaodahong opened this issue Jul 25, 2024 · 4 comments
Closed
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@shaodahong
Copy link

shaodahong commented Jul 25, 2024

React version:
18.3.1

Steps To Reproduce

When I use remix to stream render a page, sometimes garbled characters appear on the page when my data contains Chinese characters. I saw through debugging that react-dom inserts null characters when parsing, which causes an exception during merging.

const {read, written} = textEncoder.encodeInto(stringChunk, target);

img_v3_02d4_942e9e0c-fa2a-4465-af45-b9aa00e80d6g
img_v3_02d4_7b3ede95-8807-4f12-9214-d160ed0f7e9g

and when textEncoder.encodeInto exec
img_v3_02d4_e966adc3-c565-4b4c-abdc-0fa90a5eb0eg

Due to business issues, I can only provide a short reproducible fragment

var util = require('util')

var textEncoder = new util.TextEncoder()

var target = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])

textEncoder.encodeInto(
  '__remixContext.r("routes/page.$pageName", "getConfig", {"headTitle":"升级有礼","title":"有礼升级至新版立得块优惠券20"',
  target
)
console.log(new TextDecoder().decode(target))
// result: __remixContext.r("routes/page.$pageName", "getConfig", {"headTitle":"升级有礼","title":"有��

The current behavior

When transmitting Chinese data, sometimes garbled code can occur

The expected behavior

streaming original data

@shaodahong shaodahong added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Jul 25, 2024
@shaodahong
Copy link
Author

uh, ok, i find it fix in #26228, However there are issues in 18.3.1 still, so maybe we should try canary or wait for 19?

@eps1lon
Copy link
Collaborator

eps1lon commented Jul 26, 2024

I'm not sure how Remix handles React compatibility. I think it's mainly around react-router being compatible with 19 and that's planned for react-router v7 which isn't out yet.

Best to open an issue on https://github.com/remix-run/remix/ to start tracking React 19 compat.

@shaodahong
Copy link
Author

I'm not sure how Remix handles React compatibility. I think it's mainly around react-router being compatible with 19 and that's planned for react-router v7 which isn't out yet.

Best to open an issue on https://github.com/remix-run/remix/ to start tracking React 19 compat.

Thanks for the prompt reply, I'll pin the version to 18.3.0-canary-c3048aab4-20240326 for now, it seems to be the last canary version of 18, 19 is a bit flaky and for actual production project we may need more comprehensive testing

@eps1lon
Copy link
Collaborator

eps1lon commented Jul 26, 2024

19 is a bit flaky and for actual production project we may need more comprehensive testing

Curious what's flaky in that version. This would be valuable feedback before 19 goes stable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

2 participants