v5: Stuck in infinite loop in some cases
liuxingbaoyu opened this issue · comments
Before you open this issue, please complete the following tasks:
- use the search bar at the top of the page to search this repository for similar issues or discussions that have already been opened.
- if you are looking for help from the gulp team or community, open a discussion.
- if you think there is a problem with the plugin you're using, open a discussion.
- if you think there is a bug in our code, open this issue.
What were you expecting to happen?
Works like v4
What actually happened?
Stuck in an infinite loop until OOM.
Please give us a sample of your gulpfile
I tried to find a minimal reproduction but failed.
So this example needs to be run in the https://github.com/babel/babel repository.
Clone https://github.com/babel/babel and run yarn
.
Then replace Gulpfile.mjs
with the following code and run yarn gulp
to reproduce.
import gulp from "gulp";
const defaultPackagesGlob = "./@(codemods|packages|eslint)/*";
gulp.task("default", function () {
return gulp
.src(`${defaultPackagesGlob}/src/**/*.d.ts`)
.pipe(gulp.dest("./test"));
});
Terminal output / screenshots
$ gulp
<--- Last few GCs --->
[2080:0x5fe0360] 2292081 ms: Scavenge 3997.4 (4127.4) -> 3985.4 (4127.7) MB, 5.89 / 0.00 ms (average mu = 0.249, current mu = 0.057) task;
[2080:0x5fe0360] 2292139 ms: Scavenge 3998.0 (4127.9) -> 3986.0 (4128.2) MB, 5.23 / 0.00 ms (average mu = 0.249, current mu = 0.057) task;
[2080:0x5fe0360] 2295987 ms: Mark-Compact 3999.0 (4128.7) -> 3979.8 (4129.2) MB, 3794.78 / 0.00 ms (average mu = 0.263, current mu = 0.274) task; scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----
1: 0xcd8bd6 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [gulp bundle-dts]
2: 0x10aed20 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [gulp bundle-dts]
3: 0x10af007 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [gulp bundle-dts]
4: 0x12cdfe5 [gulp bundle-dts]
5: 0x12ce4be [gulp bundle-dts]
6: 0x12e36e6 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [gulp bundle-dts]
7: 0x12e4209 [gulp bundle-dts]
8: 0x12e4818 [gulp bundle-dts]
9: 0x1a[34](https://github.com/babel/babel/actions/runs/8594917993/job/23548824406?pr=16413#step:7:35)081 [gulp bundle-dts]
Please provide the following information:
- OS & version [e.g. MacOS Catalina 10.15.4]: Windows 11
- node version (run
node -v
): v21.7.3 - npm version (run
npm -v
): 10.5.0 - gulp version (run
gulp -v
): 5.0.0
Additional information
Thanks for the report. I made a fix in glob-stream that only traverses the glob parent directory, but you are using a glob in the first segment so it will still traverse the node_modules and other directories.
I'm not sure how to fix this easily in our new glob-stream implement, but I believe a workaround would be to separate the glob parts in parens into 3 separate globs.
Thank you for your quick reply!
I tried splitting it, unfortunately the issue still exists.🤔
import gulp from "gulp";
const defaultPackagesGlob = function (path) {
return ["./codemods/*", "./packages/*", "./eslint/*"].map(p => p + path);
};
gulp.task("default", function () {
return gulp
.src(defaultPackagesGlob("/src/**/*.d.ts"))
.pipe(gulp.dest("./test"));
});
we met this problem. our code:
function copyLocalesJSON() {
return src('**/locales/*.json', {
cwd: fileURLToPath(PKG_PATH),
ignore: ['**/node_modules/**', '**/dist/**'],
}).pipe(dest(fileURLToPath(DIST_PATH)))
}
and we have a lot of recursively linked node_modules.
I workaround this by force "glob-stream" to be "7.0.0" not "8.2.0"