Comments (8)
I think you're expecting too much from snapshots. Snapshots in v8 are very fragile and based on my experience I believe they are intended to cache only parsed/compiled JS code not to cache a "warmed up" application with lots of state on the heap.
from isolated-vm.
I don't think this is going to be possible. The API for creating snapshots in v8 is pretty locked down with lots of restrictions. Basically, the way you go about creating a snapshot is very different from the way you go about using an isolate for general purposes. You can put as many scripts as you want into the snapshot initialization though, that gives you lots of freedom for what goes into your snapshot.
from isolated-vm.
That's unfortunate, I'll see if I can get something done with the current snapshot feature, but I don't think this is going to work out the way I want to.
Thanks for the reply anyways.
from isolated-vm.
@laverdet we'd also be grateful for this feature. is there any chance this will be implemented? thx.
from isolated-vm.
@lev-kazakov it's impossible. The snapshot feature is intended to just cache library code.
from isolated-vm.
@laverdet thx, another question if i may:
will it be possible for ivm.Isolate.createSnapshot()
to receive a third parameter, say "global"
/"bindings"
/"polyfills"
that will receive a set of transferrables/references, and make them available from the global scope of the isolate?
e.g if i do something like this:
const snapshot = ivm.Isolate.createSnapshot([{code: `log('crap')`}], undefined, {
log: new ivm.Reference(function(...args) {
console.log(...args);
}
})
then log
would be available to any script on the scripts
array.
if this is realistic, i'll open a new issue of course :)
from isolated-vm.
@lev-kazakov that's not possible either because the 3rd parameter in your example would only last as long as the nodejs process is alive. You can save a snapshot to disk and load it into any number of new nodejs processes, and in those processes your log function wouldn't exist anymore.
from isolated-vm.
@laverdet maybe this can be done by providing an additional polyfills
option to the options
object in new ivm.Isolate(options)
.
it will be the responsibility of the user to creating an isolate from snapshot to provide the same polyfills (by name) used to create the snapshot.
from isolated-vm.
Related Issues (20)
- How would one go about making an http request. HOT 7
- 4.7.0 and 4.7.1 missing on npm
- Strange `symbol not found` error on docker image `node:20.11.0-alpine` HOT 3
- Use after free HOT 1
- An error occurred while using inspector-example.js HOT 1
- Bun.js Unable to Execute Isolated-VM HOT 2
- Minimal representation of isolate code hanging the entire process
- _ZNK2v810StackFrame11GetLocationEv: symbol not found HOT 5
- Cannot get returned value after bundling using webpack HOT 5
- Ability to capture swallowed promise rejections/errors HOT 1
- Heap out of memory HOT 1
- `memoryLimit` not being applied to isolate
- #<Promise> could not be cloned. HOT 2
- Question about maintenance mode HOT 2
- Segmentation fault while trying to use native-example from this repo HOT 2
- Environment can be null HOT 3
- How to add --no-node-snapshot option when running the command npx jest? HOT 1
- TypeError: #<Promise> could not be cloned. HOT 1
- yarn add isolated-vm fails with a build error on latest stable versions HOT 11
- Docker build error in git action with linux/arm64 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from isolated-vm.