You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a load() handler returns lots of strings, some of which contain extended characters.
in serialize_data_node(), svelte uses devalue to turn it into a json string.
conststringified=devalue.stringify(node.data);
later, on the client, response.json() gets called and fails because the json is invalid.
Reproduction
I have a 30k line payload causing the trouble... so its' a bit hard to pinpoint it, but you can get an idea of what can cause the problem with this toy snippet, which reproduces the basic problem:
>JSON.parse(devalue.stringify(decoder.write(Buffer.from([0x00,0x11]))))>constdevalue=awaitimport('devalue');>const{ StringDecoder }=require('node:string_decoder');>constdecoder=newStringDecoder('utf8');// intentionally bad input string:>devalue.stringify(decoder.write(Buffer.from([0x00,0x11])))'["\\u0000\x11"]'>JSON.parse(devalue.stringify(decoder.write(Buffer.from([0x00,0x11]))))Uncaught SyntaxError: Unexpectedtoken◄inJSONatposition8// expected it would roundtrip fine like built-in:>JSON.parse(JSON.stringify(decoder.write(Buffer.from([0x00,0x11]))))'\x00\x11'
Logs
I get a variety of errors on the client, depending on which character is bad
Bad control character in string literal in JSON at position 18230
Uncaught SyntaxError SyntaxError: Unexpected token � in JSON at position 18168
Are you serving your app in a way that it is not getting the appropriate charset=utf-8 part of the Content-Type header? That was the situation I was trying to deal with in that devalue issue.
Describe the bug
a load() handler returns lots of strings, some of which contain extended characters.
in serialize_data_node(), svelte uses devalue to turn it into a json string.
later, on the client, response.json() gets called and fails because the json is invalid.
Reproduction
I have a 30k line payload causing the trouble... so its' a bit hard to pinpoint it, but you can get an idea of what can cause the problem with this toy snippet, which reproduces the basic problem:
Logs
System Info
Severity
serious, but I can work around it
Additional Information
No response
The text was updated successfully, but these errors were encountered: