From 6e5280b1b82d289b89afae63aad380a9c6fc3f4b Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Thu, 10 Oct 2024 02:06:46 -0700 Subject: [PATCH] pm: fix assertion failure when printing lockfile summary after adding git transitive dependency --- src/install/install.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/install/install.zig b/src/install/install.zig index 95e6cb674801a..81e5eba898287 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -12307,6 +12307,16 @@ pub const PackageManager = struct { this.names = packages.items(.name); this.bins = packages.items(.bin); this.resolutions = packages.items(.resolution); + + // fixes an assertion failure where a transitive dependency is a git dependency newly added to the lockfile after the list of dependencies has been resized + // this assertion failure would also only happen after the lockfile has been written to disk and the summary is being printed. + if (this.successfully_installed.bit_length < this.lockfile.packages.len) { + const new = Bitset.initEmpty(bun.default_allocator, this.lockfile.packages.len) catch bun.outOfMemory(); + var old = this.successfully_installed; + defer old.deinit(bun.default_allocator); + old.copyInto(new); + this.successfully_installed = new; + } } /// Install versions of a package which are waiting on a network request