VM2 does not seem to be compatible with StackBlitz
mhevery opened this issue · 3 comments
mhevery commented
We are trying to get Builder.io working in StackBlitz, which internally uses vm2 The VM2 seems to fail its own invariants.
Builder custom code error: Should not happen in var _virtual_index="context.builderContent.data.title: ".concat(context.builderContent.data.title);return _virtual_index VMError: Should not happen
at localUnexpected (/home/projects/nextjs-r12buu/node_modules/vm2/lib/setup-sandbox.js:60:9)
at eval (/home/projects/nextjs-r12buu/node_modules/vm2/lib/setup-sandbox.js:293:12)
at new VM (/home/projects/nextjs-r12buu/node_modules/vm2/lib/vm.js:279:82)
at l (/home/projects/nextjs-r12buu/node_modules/@builder.io/react/dist/builder-react.cjs.js:1:6695)
at BuilderBlock.getElement (/home/projects/nextjs-r12buu/node_modules/@builder.io/react/dist/builder-react.cjs.js:1:14762)
at BuilderBlock.contents (/home/projects/nextjs-r12buu/node_modules/@builder.io/react/dist/builder-react.cjs.js:1:18348)
at eval (/home/projects/nextjs-r12buu/node_modules/@builder.io/react/dist/builder-react.cjs.js:1:18659)
at renderContextConsumer (/home/projects/nextjs-r12buu/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5905:21)
at renderElement (/home/projects/nextjs-r12buu/node_modules/react-dom/cjs/react-dom-server.browser.development.js:6023:11)
Reproduction steps:
- navigate to StackBlitz This should open up a window in which the Builder SDK should boot up. During the boot process, you should see the above error.
- Open dev-tools and globally search for
VMError('Should not happen');
this should opensetup-sandbox.js:
file. - Place breakpoint in
function localUnexpected() {
return new VMError('Should not happen');
}
- In the terminal window,
Ctrl-C
to break out of the server. - Run
npm run dev:debug
to reproduce the error. This time the DevTools should stop in the debugger.
XmiliaH commented
This is intended. They do not use the node's vm module and install a custom prepareStackTrace
property on the Error object before VM2 does. We cannot change this property and so need to error out to prevent escapes.
mhevery commented
Is thereA workaround for this?
…On Thu, Oct 6, 2022 at 10:06 AM XmiliaH ***@***.***> wrote:
This is intended. They do not use the node's vm module and install a
custom prepareStackTrace property on the Error object before VM2 does. We
cannot change this property and so need to error out to prevent escapes.
—
Reply to this email directly, view it on GitHub
<#479 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA3KT4PPEH4ZH5NIFBPPKTWB4BK7ANCNFSM6AAAAAAQ62DDQE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
XmiliaH commented
Aside from just patching the code there should be no workaround as it is unsafe.