Skip to content

Commit dc80055

Browse files
committed
fix: address release pipeline copyJsModule race condition
1 parent fc04c59 commit dc80055

1 file changed

Lines changed: 30 additions & 19 deletions

File tree

configs/jsactions/rollup-plugin-collect-dependencies.mjs

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -178,30 +178,41 @@ export async function copyJsModule(moduleSourcePath, to) {
178178
actualSourcePath = realpathSync(moduleSourcePath);
179179
}
180180

181-
cpSync(actualSourcePath, to, {
182-
recursive: true,
183-
dereference: true, // Follow symlinks and copy the actual files
184-
filter: (src, dest) => {
185-
const relativePath = src.replace(actualSourcePath, "").replace(/^[\\/]/, "");
186-
187-
// Skip certain directories
188-
if (relativePath.match(/[\\/](android|ios|windows|mac|jest|github|gradle|__.*__|docs|example.*)[\\/]/)) {
189-
return false;
190-
}
181+
try {
182+
cpSync(actualSourcePath, to, {
183+
recursive: true,
184+
dereference: true, // Follow symlinks and copy the actual files
185+
filter: (src, dest) => {
186+
const relativePath = src.replace(actualSourcePath, "").replace(/^[\\/]/, "");
187+
188+
// Skip certain directories
189+
if (
190+
relativePath.match(/[\\/](android|ios|windows|mac|jest|github|gradle|__.*__|docs|example.*)[\\/]/)
191+
) {
192+
return false;
193+
}
191194

192-
// Skip certain file types
193-
if (relativePath.match(/\.(config|setup)\.|\.podspec$|\.flow$/)) {
194-
return false;
195-
}
195+
// Skip certain file types
196+
if (relativePath.match(/\.(config|setup)\.|\.podspec$|\.flow$/)) {
197+
return false;
198+
}
199+
200+
// Include LICENSE files
201+
if (relativePath.match(/license/i)) {
202+
return true;
203+
}
196204

197-
// Include LICENSE files
198-
if (relativePath.match(/license/i)) {
199205
return true;
200206
}
201-
202-
return true;
207+
});
208+
} catch (error) {
209+
// Handle race condition: if another parallel build process already created this directory,
210+
// ignore EEXIST errors and verify the directory now exists
211+
if (error.code === "EEXIST" && existsSync(to)) {
212+
return;
203213
}
204-
});
214+
throw error;
215+
}
205216
}
206217

207218
function getModuleName(modulePath) {

0 commit comments

Comments
 (0)