#Parsing include_str!'d large file with serde_json::from_str crashes

1 messages · Page 1 of 1 (latest)

sacred rivet
#

Hi!
I'm running the following code in my main function, before rendering the yew app. So maybe this isn't the right place to ask, but I don't really now where else I'd post.

let job_results_str = include_str!("../../cached/job_results.json");
log!(format!("job results str: {}", job_results_str));
let default_job_results: FinishedJobState = serde_json::from_str(job_results_str).expect("Error parsing job_results.json file!");
log!(format!("default job results: {:#?}", &default_job_results));

The first log! statement is reached, the second isn't. Instead, the browser (firefox-dev-edition) prints the following error message:

Uncaught (in promise) RuntimeError: unreachable executed
    finalizeInit http://localhost:3000/assets/frontend-4410b92347e1e5e6.js:1236
    init http://localhost:3000/assets/frontend-4410b92347e1e5e6.js:1268
    async* http://localhost:3000/profiling:19
frontend-4410b92347e1e5e6_bg.wasm:6635320:1
    init http://localhost:3000/assets/frontend-4410b92347e1e5e6.js:1269
    InterpretGeneratorResume self-hosted:1359
    AsyncFunctionNext self-hosted:756
    (Async: async)
    <anonymous> http://localhost:3000/profiling:19

The file I'm include_str!'ing is 12k lines of json. When I make the file smaller (tested about 1,5k lines), the error doesn't appear.

Is this a bug in serde_json or a general limitation of the wasm platform?

I'd be very happy if somebody could tell me whether I should report this as a bug somewhere.

dusk fiber
#

Yew sets console_error_panic_hook, i think your code needs to set it first to get a more friendly error

sacred rivet
#

Ah, that's the problem! So it's probably a normal panic. Thank you!