Fix crash when NaN, Inf or -Inf in frontend state. (#744)

* Add json5 package
* Use json5 instead of JSON when parsing state updates
This commit is contained in:
jonatan 2023-03-29 20:36:01 +02:00 committed by GitHub
parent a2f86f9fbb
commit e7fc4b5d7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -32,6 +32,7 @@
"remark-gfm": "^3.0.1", "remark-gfm": "^3.0.1",
"remark-math": "^5.1.1", "remark-math": "^5.1.1",
"socket.io-client": "^4.5.4", "socket.io-client": "^4.5.4",
"victory": "^36.6.8" "victory": "^36.6.8",
"json5": "^2.2.3"
} }
} }

View File

@ -1,6 +1,7 @@
// State management for Pynecone web apps. // State management for Pynecone web apps.
import axios from "axios"; import axios from "axios";
import io from "socket.io-client"; import io from "socket.io-client";
import JSON5 from "json5";
// Global variable to hold the token. // Global variable to hold the token.
let token; let token;
@ -175,7 +176,7 @@ export const connect = async (
// On each received message, apply the delta and set the result. // On each received message, apply the delta and set the result.
socket.current.on("event", function (update) { socket.current.on("event", function (update) {
update = JSON.parse(update); update = JSON5.parse(update);
applyDelta(state, update.delta); applyDelta(state, update.delta);
setResult({ setResult({
processing: true, processing: true,