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
{{ message }}
Repository navigation
evalCode returns "[object Object]" for large objects when memory limit is set #241
When a memory limit is set, objects with properties larger than a certain threshold (but still within the memory limit) will start to be output as the string "[object Object]".
The threshold where this starts happening appears to scale with memory limit, for example:
With memory limit 100_000
Property length 50_000 -> Works as expected
Property length 70_000 -> "[object Object]"
With memory limit 200_000
Property length 70_000 -> Works as expected
Property length 140_000 -> "[object Object]"
Can be reproduced with this example on quickjs-emscripten 0.31.0
import{getQuickJS}from"quickjs-emscripten";asyncfunctionmain(){constQuickJS=awaitgetQuickJS();constvm=QuickJS.newContext();// Set a memory limitvm.runtime.setMemoryLimit(100_000);constresult=vm.evalCode('const test = { eg: "a".repeat(70_000) }; test;');if(result.error){console.log("Execution failed:",JSON.stringify(vm.dump(result.error)));result.error.dispose();}else{console.log("Success:",JSON.stringify(vm.dump(result.value)));result.value.dispose();}vm.dispose();}main();
vm.dump is respecting your memory limit. If you don't have enough memory to perform JSON conversion, then it will fall back to doing essentially String(value); it falls back to String(value) when it encounters any error converting to JSON.
You can either expand/disable the memory limit around calls to vm.dump, or you can inspect the returned QuickJSHandle directly and use native iteration over its properties instead of serializing (so you use O(1) memory per call) the entire value at once (using another O(N) memory)
Activity
justjake commentedon Feb 16, 2026
vm.dumpis respecting your memory limit. If you don't have enough memory to perform JSON conversion, then it will fall back to doing essentiallyString(value); it falls back toString(value)when it encounters any error converting to JSON.You can either expand/disable the memory limit around calls to
vm.dump, or you can inspect the returned QuickJSHandle directly and use native iteration over its properties instead of serializing (so you use O(1) memory per call) the entire value at once (using another O(N) memory)Improve QTS_Dump: handle inherited props, better fallback (#241)
Improve QTS_Dump: handle inherited props, better fallback (#241) (#250)
Improve QTS_Dump: handle inherited props, better fallback (justjake#241…