Commit a2f14e7
authored
Avoid double JSON encode/decode for socket.io (#4449)
* Avoid double JSON encode/decode for socket.io
socket.io (python and js) already has a built in mechanism for JSON encoding
and decoding messages over the websocket. To use it, we pass a custom `json`
namespace which uses `format.json_dumps` (leveraging reflex serializers) to encode the
messages. This avoids sending a JSON-encoded string of JSON over the wire, and
reduces the number of serialization/deserialization passes over the message
data.
The side benefit is that debugging websocket messages in browser tools displays
the parsed JSON hierarchy and is much easier to work with.
* JSON5.parse in on_upload_progress handler responses1 parent 053cbe7 commit a2f14e7
File tree
4 files changed
+97
-63
lines changed- reflex
- .templates/web/utils
- utils
- tests/units
4 files changed
+97
-63
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
303 | | - | |
| 303 | + | |
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
| |||
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
| 410 | + | |
| 411 | + | |
410 | 412 | | |
411 | 413 | | |
412 | 414 | | |
| |||
443 | 445 | | |
444 | 446 | | |
445 | 447 | | |
446 | | - | |
447 | | - | |
| 448 | + | |
448 | 449 | | |
449 | 450 | | |
450 | 451 | | |
| |||
456 | 457 | | |
457 | 458 | | |
458 | 459 | | |
459 | | - | |
| 460 | + | |
460 | 461 | | |
461 | 462 | | |
462 | 463 | | |
| |||
497 | 498 | | |
498 | 499 | | |
499 | 500 | | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
517 | 526 | | |
518 | 527 | | |
519 | 528 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
363 | 364 | | |
364 | 365 | | |
365 | 366 | | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
366 | 371 | | |
367 | 372 | | |
368 | 373 | | |
| |||
1543 | 1548 | | |
1544 | 1549 | | |
1545 | 1550 | | |
1546 | | - | |
| 1551 | + | |
1547 | 1552 | | |
1548 | 1553 | | |
1549 | 1554 | | |
| |||
1556 | 1561 | | |
1557 | 1562 | | |
1558 | 1563 | | |
1559 | | - | |
| 1564 | + | |
1560 | 1565 | | |
1561 | 1566 | | |
1562 | 1567 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
664 | 664 | | |
665 | 665 | | |
666 | 666 | | |
667 | | - | |
| 667 | + | |
668 | 668 | | |
669 | 669 | | |
670 | 670 | | |
671 | 671 | | |
| 672 | + | |
672 | 673 | | |
673 | 674 | | |
674 | 675 | | |
675 | 676 | | |
676 | 677 | | |
677 | 678 | | |
678 | | - | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
679 | 683 | | |
680 | 684 | | |
681 | 685 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1840 | 1840 | | |
1841 | 1841 | | |
1842 | 1842 | | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
1843 | 1861 | | |
1844 | 1862 | | |
1845 | 1863 | | |
| |||
1856 | 1874 | | |
1857 | 1875 | | |
1858 | 1876 | | |
1859 | | - | |
| 1877 | + | |
1860 | 1878 | | |
1861 | 1879 | | |
1862 | 1880 | | |
| |||
1960 | 1978 | | |
1961 | 1979 | | |
1962 | 1980 | | |
1963 | | - | |
1964 | | - | |
1965 | | - | |
1966 | | - | |
1967 | | - | |
1968 | | - | |
1969 | | - | |
1970 | | - | |
1971 | | - | |
1972 | | - | |
1973 | | - | |
1974 | | - | |
1975 | | - | |
1976 | | - | |
1977 | | - | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
1978 | 1994 | | |
1979 | 1995 | | |
1980 | 1996 | | |
| |||
2156 | 2172 | | |
2157 | 2173 | | |
2158 | 2174 | | |
2159 | | - | |
| 2175 | + | |
2160 | 2176 | | |
2161 | | - | |
| 2177 | + | |
2162 | 2178 | | |
2163 | 2179 | | |
2164 | | - | |
2165 | | - | |
| 2180 | + | |
| 2181 | + | |
2166 | 2182 | | |
2167 | 2183 | | |
2168 | 2184 | | |
2169 | 2185 | | |
2170 | 2186 | | |
2171 | | - | |
2172 | | - | |
2173 | | - | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
2174 | 2190 | | |
2175 | | - | |
2176 | | - | |
| 2191 | + | |
| 2192 | + | |
2177 | 2193 | | |
2178 | 2194 | | |
2179 | 2195 | | |
2180 | 2196 | | |
2181 | | - | |
2182 | | - | |
2183 | | - | |
2184 | | - | |
2185 | | - | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
2186 | 2202 | | |
2187 | 2203 | | |
2188 | 2204 | | |
2189 | 2205 | | |
2190 | 2206 | | |
2191 | 2207 | | |
2192 | | - | |
2193 | | - | |
2194 | | - | |
2195 | | - | |
2196 | | - | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
2197 | 2213 | | |
2198 | 2214 | | |
2199 | 2215 | | |
2200 | 2216 | | |
2201 | | - | |
2202 | | - | |
2203 | | - | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
2204 | 2220 | | |
2205 | 2221 | | |
2206 | 2222 | | |
| |||
0 commit comments