Fix some things

This commit is contained in:
Jarred Sumner
2024-01-26 00:47:51 -08:00
parent 2eac723832
commit 157a22c0eb
3 changed files with 34 additions and 16 deletions

View File

@@ -1625,6 +1625,24 @@ pub const MiniEventLoop = struct {
}
}
pub fn tickWithoutIdle(
this: *MiniEventLoop,
context: *anyopaque,
) void {
defer this.onAfterEventLoop();
while (true) {
_ = this.tickConcurrentWithCount();
while (this.tasks.readItem()) |task| {
task.run(context);
}
this.loop.tickWithoutIdle();
if (this.tasks.count == 0 and this.tickConcurrentWithCount() == 0) break;
}
}
pub fn tick(
this: *MiniEventLoop,
context: *anyopaque,
@@ -1748,10 +1766,10 @@ pub const AnyEventLoop = union(enum) {
switch (this.*) {
.js => {
this.js.tick();
this.js.autoTick();
this.js.autoTickActive();
},
.mini => {
this.mini.tickOnce(context);
this.mini.tickWithoutIdle(context);
},
}
}

View File

@@ -2162,12 +2162,12 @@ pub const PackageManager = struct {
}
pub fn tickLifecycleScripts(this: *PackageManager) void {
this.event_loop.tick(this, hasNoMorePendingLifecycleScripts);
this.event_loop.tickOnce(this);
}
pub fn sleep(this: *PackageManager) void {
Output.flush();
this.event_loop.tickOnce(this);
this.event_loop.tick(this, hasNoMorePendingLifecycleScripts);
}
const DependencyToEnqueue = union(enum) {
@@ -6310,7 +6310,7 @@ pub const PackageManager = struct {
},
};
manager.lockfile = try ctx.allocator.create(Lockfile);
JSC.MiniEventLoop.global = &manager.event_loop.mini;
if (!manager.options.enable.cache) {
manager.options.enable.manifest_cache = false;
manager.options.enable.manifest_cache_control = false;
@@ -8860,7 +8860,7 @@ pub const PackageManager = struct {
this.sleep();
} else {
this.sleep();
this.tickLifecycleScripts();
}
this.finished_installing.store(true, .Monotonic);

View File

@@ -27,6 +27,8 @@ pub const LifecycleScriptSubprocess = struct {
timer: ?Timer = null,
pub usingnamespace bun.New(@This());
pub const min_milliseconds_to_log = 500;
pub var alive_count: std.atomic.Value(usize) = std.atomic.Value(usize).init(0);
@@ -491,17 +493,13 @@ pub const LifecycleScriptSubprocess = struct {
pub fn deinit(this: *LifecycleScriptSubprocess) void {
this.resetPolls();
if (this.process) |process| {
this.process = null;
process.detach();
process.deref();
}
if (!this.manager.options.log_level.isVerbose()) {
this.stdout.buffer.clearAndFree();
this.stderr.buffer.clearAndFree();
}
this.manager.allocator.destroy(this);
this.destroy();
}
pub fn spawnPackageScripts(
@@ -510,10 +508,12 @@ pub const LifecycleScriptSubprocess = struct {
envp: [:null]?[*:0]u8,
comptime log_level: PackageManager.Options.LogLevel,
) !void {
var lifecycle_subprocess = try manager.allocator.create(LifecycleScriptSubprocess);
lifecycle_subprocess.scripts = list.items;
lifecycle_subprocess.manager = manager;
lifecycle_subprocess.envp = envp;
var lifecycle_subprocess = LifecycleScriptSubprocess.new(.{
.manager = manager,
.envp = envp,
.scripts = list.items,
.package_name = list.first().package_name,
});
if (comptime log_level.isVerbose()) {
Output.prettyErrorln("<d>[LifecycleScriptSubprocess]<r> Starting scripts for <b>\"{s}\"<r>", .{