mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
deinit persistent in dynamic import
This commit is contained in:
@@ -1668,6 +1668,11 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
||||
specifier: []const u8,
|
||||
module: v8.Persistent(v8.Module),
|
||||
resolver: v8.Persistent(v8.PromiseResolver),
|
||||
|
||||
pub fn deinit(ev: *@This()) void {
|
||||
ev.module.deinit();
|
||||
ev.resolver.deinit();
|
||||
}
|
||||
};
|
||||
|
||||
const ev_data = try self.context_arena.create(EvaluationData);
|
||||
@@ -1684,6 +1689,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
||||
const cb_isolate = cb_info.getIsolate();
|
||||
const cb_context = cb_isolate.getCurrentContext();
|
||||
const data: *EvaluationData = @ptrCast(@alignCast(cb_info.getExternalValue()));
|
||||
defer data.deinit();
|
||||
const cb_module = data.module.castToModule();
|
||||
const cb_resolver = data.resolver.castToPromiseResolver();
|
||||
|
||||
@@ -1698,6 +1704,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
||||
const cb_info = v8.FunctionCallbackInfo{ .handle = info.? };
|
||||
const cb_context = cb_info.getIsolate().getCurrentContext();
|
||||
const data: *EvaluationData = @ptrCast(@alignCast(cb_info.getExternalValue()));
|
||||
defer data.deinit();
|
||||
const cb_resolver = data.resolver.castToPromiseResolver();
|
||||
|
||||
log.err(.js, "dynamic import failed", .{ .specifier = data.specifier });
|
||||
@@ -1710,6 +1717,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
||||
.specifier = specifier,
|
||||
.line = try_catch.sourceLineNumber() orelse 0,
|
||||
});
|
||||
defer ev_data.deinit();
|
||||
const error_msg = v8.String.initUtf8(iso, "Evaluation is a promise");
|
||||
_ = resolver.reject(ctx, error_msg.toValue());
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user