Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Conversion to native ArrayBuffer and TypedArray types is inefficient #21

Open
pfrazee opened this issue Jul 1, 2020 · 0 comments
Open

Comments

@pfrazee
Copy link
Member

pfrazee commented Jul 1, 2020

As far as I can tell, the nodejs vm (or vm2) does not use the ArrayBuffer or TypedDataView objects that are native to the VM's realm, causing things like v instanceof ArrayBuffer to "incorrectly" fail when running scripts in the VM.

To solve that, I'm currently converting responses to the correct type. On top of that, some functions return node's Buffer type, which we also have to convert.

To do that, I'm injecting a frontmatter/preload into the VM scripts: https://github.com/beakerbrowser/bkr/blob/master/lib/run/preload.js

I'm opening this issue because my solution sucks and it'd be much nicer if this data types correctly converted over.

(FWIW, I'm generally not pleased with having to run rollup on modules to produce a bundle because it fucks up stack traces. We might be able to solve that with some kind of source-map manipulation on stacks.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant