Skip to content

Commit c798e1a

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 f533f76 commit c798e1a

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
@@ -108,6 +108,13 @@ function abbreviateReplacer(_, arg) {
108108
return arg;
109109
}
110110

111+
function bigIntReplacer(_, arg) {
112+
if (typeof arg === 'bigint') {
113+
return Number(arg);
114+
}
115+
return arg;
116+
}
117+
111118
/**
112119
* @param { ReturnType<typeof managerPort> } port
113120
*/
@@ -123,7 +130,7 @@ function makeWorker(port) {
123130
*/
124131
function makeConsole(tag) {
125132
const log = level => (...args) => {
126-
const jsonSafeArgs = JSON.parse(`${q(args)}`);
133+
const jsonSafeArgs = JSON.parse(JSON.stringify(args, bigIntReplacer));
127134
port.send(['console', level, tag, ...jsonSafeArgs]);
128135
};
129136
const cons = {

0 commit comments

Comments
 (0)