Переглянути джерело

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

* Add json5 package
* Use json5 instead of JSON when parsing state updates
jonatan 2 роки тому
батько
коміт
e7fc4b5d7c

+ 2 - 1
pynecone/.templates/web/package.json

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

+ 2 - 1
pynecone/.templates/web/utils/state.js

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