Skip to content

Commit 82d873d

Browse files
warnerdckc
authored andcommitted
fix(swingset): supervisor-xs: tolerate console.log(BigInt)
We serialize console.log arguments (to send over the pipe to the kernel process) with JSON.stringify, which doesn't tolerate BigInt. Use a simple replacer to turn them into Numbers first; we can tolerate the loss of fidelity for console.log. closes #2936
1 parent 552370c commit 82d873d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/SwingSet/src/kernel/vatManager/supervisor-subprocess-xsnap.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ function abbreviateReplacer(_, arg) {
109109
return arg;
110110
}
111111

112+
function bigIntReplacer(_, arg) {
113+
if (typeof arg === 'bigint') {
114+
return Number(arg);
115+
}
116+
return arg;
117+
}
118+
112119
/**
113120
* @param { ReturnType<typeof managerPort> } port
114121
*/
@@ -124,7 +131,7 @@ function makeWorker(port) {
124131
*/
125132
function makeConsole(tag) {
126133
const log = level => (...args) => {
127-
const jsonSafeArgs = JSON.parse(`${q(args)}`);
134+
const jsonSafeArgs = JSON.parse(JSON.stringify(args, bigIntReplacer));
128135
port.send(['console', level, tag, ...jsonSafeArgs]);
129136
};
130137
const cons = {

0 commit comments

Comments
 (0)