boopus_the_snootus
boopus_the_snootus
DDeno
Created by boopus_the_snootus on 9/28/2023 in #help
`WARNING: v8::OwnedIsolate for snapshot was leaked` and/or crash after using snapshot
On startup, I create a runtime:
let js_runtime = JsRuntimeForSnapshot::new(deno_core::RuntimeOptions {
module_loader: Some(Rc::new(FsModuleLoader)),
extensions: options.extensions,
..Default::default()
});
let snapshot = js_runtime.snapshot().to_vec();
let js_runtime = JsRuntimeForSnapshot::new(deno_core::RuntimeOptions {
module_loader: Some(Rc::new(FsModuleLoader)),
extensions: options.extensions,
..Default::default()
});
let snapshot = js_runtime.snapshot().to_vec();
Then I will recreate the runtime, since snapshot consumes it:
let _snapshot = Snapshot::Boxed(snapshot.clone().into_boxed_slice());
JsRuntimeForSnapshot::new(deno_core::RuntimeOptions {
startup_snapshot: Some(_snapshot),
module_loader: Some(Rc::new(FsModuleLoader)),
..Default::default()
})
let _snapshot = Snapshot::Boxed(snapshot.clone().into_boxed_slice());
JsRuntimeForSnapshot::new(deno_core::RuntimeOptions {
startup_snapshot: Some(_snapshot),
module_loader: Some(Rc::new(FsModuleLoader)),
..Default::default()
})
But the next time I reload from the snapshot in this way I get WARNING: v8::OwnedIsolate for snapshot was leaked, and some of the extensions result in a crash:
(exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)
(exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)
My extremely roundabout method here seems off to me So how do I actually use snapshot correctly to avoid this
67 replies
DDeno
Created by boopus_the_snootus on 9/27/2023 in #help
deno_console not being properly instantiated?
Not sure if it's indended, or if I am missing a step, but several core extensions, for example the deno_console crate, do not: - specify an entrypoint for esm, leading to a panic on startup - add their APIs to window or global, making them inert by default In my implementation I've had to include a small extension of my own along-side console that does the following:
import { Console } from 'ext:deno_console/01_console.js'; // If nothing imports this file, the runtime will panic
const core = globalThis.Deno.core;
globalThis.console = new Console((msg, level) => core.print(msg, level > 1)); // The console never actually gets built so let's do that
import { Console } from 'ext:deno_console/01_console.js'; // If nothing imports this file, the runtime will panic
const core = globalThis.Deno.core;
globalThis.console = new Console((msg, level) => core.print(msg, level > 1)); // The console never actually gets built so let's do that
So my question; is that intended behaviour? Or did I miss a step somewhere
7 replies
DDeno
Created by boopus_the_snootus on 9/26/2023 in #help
Getting exports from an evaluated module with get_module_namespace always results in null values
Trying to get module exports like the example here The module is loaded with load_main_module, I call mod_evaluate on the ID returned, then do the below: But the value returned is always undefined Js:
export function test() { return 2;}
export function test() { return 2;}
Rust:
let module_namespace = self.deno_runtime.get_module_namespace(module_id)?;
let mut scope = self.deno_runtime.handle_scope();
let module_namespace = v8::Local::<v8::Object>::new(&mut scope, module_namespace);

let key = v8::String::new(&mut scope, "test").unwrap();
let value = module_namespace.get(&mut scope, key.into()).unwrap();

println!("{}", value.is_undefined()); // true
let module_namespace = self.deno_runtime.get_module_namespace(module_id)?;
let mut scope = self.deno_runtime.handle_scope();
let module_namespace = v8::Local::<v8::Object>::new(&mut scope, module_namespace);

let key = v8::String::new(&mut scope, "test").unwrap();
let value = module_namespace.get(&mut scope, key.into()).unwrap();

println!("{}", value.is_undefined()); // true
11 replies
DDeno
Created by boopus_the_snootus on 9/21/2023 in #help
esm_entry_point / extension macro; ReferenceError
How do I use esm_entry_point properly? I defined my extension as:
extension!(
ext_name,
ops = [op_register_entrypoint],
esm_entry_point = "ext:ext_name/js_playground.js",
esm = [ dir "src/ext", "ext_name.js" ],
);
extension!(
ext_name,
ops = [op_register_entrypoint],
esm_entry_point = "ext:ext_name/js_playground.js",
esm = [ dir "src/ext", "ext_name.js" ],
);
But I'm now getting a referenceerror about ext_name being undefined - which is odd since I can see it expands to define the struct
30 replies
DDeno
Created by boopus_the_snootus on 9/14/2023 in #help
integrating deno_web
Ok I seem to have poobrain today. Can't seem to get the deno_web extension working. The core version on that crate is outdated so I assume that's not how I'm meant to use it ... just trying to get access to atob/btoa and the other methods it provides from deno_core
3 replies
DDeno
Created by boopus_the_snootus on 3/31/2023 in #help
Unexpected token 'export' (deno_core)
Playing around with ModuleLoaders, but doesn't seem to make a difference Scripts containing the export keyword don't load due to above error How can I allow the keyword?
14 replies