Skip to content

Commit 6f40235

Browse files
committed
fix #1703: handle silent "rename" syscall failure
1 parent 2b52f3e commit 6f40235

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Unreleased
44

5+
* Fix using `npm rebuild` with the `esbuild` package ([#1703](https://github.com/evanw/esbuild/issues/1703))
6+
7+
Version 0.13.4 accidentally introduced a regression in the install script where running `npm rebuild` multiple times could fail after the second time. The install script creates a copy of the binary executable using [`link`](https://man7.org/linux/man-pages/man2/link.2.html) followed by [`rename`](https://www.man7.org/linux/man-pages/man2/rename.2.html). Using `link` creates a hard link which saves space on the file system, and `rename` is used for safety since it atomically replaces the destination.
8+
9+
However, the `rename` syscall has an edge case where it silently fails if the source and destination are both the same link. This meant that the install script would fail after being run twice in a row. With this release, the install script now deletes the source after calling `rename` in case it has silently failed, so this issue should now be fixed. It should now be safe to use `npm rebuild` with the `esbuild` package.
10+
511
* Fix invalid CSS minification of `border-radius` ([#1702](https://github.com/evanw/esbuild/issues/1702))
612

713
CSS minification does collapsing of `border-radius` related properties. For example:

lib/npm/node-install.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ function maybeOptimizePackage(binPath: string): void {
169169
// If we get here, then we know that the target location is now a binary
170170
// executable instead of a JavaScript file.
171171
isToPathJS = false;
172+
173+
// If this install script is being re-run, then "renameSync" will fail
174+
// since the underlying inode is the same (it just returns without doing
175+
// anything, and without throwing an error). In that case we should remove
176+
// the file manually.
177+
fs.unlinkSync(tempPath);
172178
} catch {
173179
// Ignore errors here since this optimization is optional
174180
}

0 commit comments

Comments
 (0)