Skip to content

Commit bb38c5d

Browse files
authored
Merge pull request webpack#7586 from samccone/sjs/fix_webpack_profiling_race
Fix race condition in profiling plugin.
2 parents 3fb49de + 735f99c commit bb38c5d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/debug/ProfilingPlugin.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,14 @@ function createTrace(outputPath) {
130130
trace,
131131
counter,
132132
profiler,
133-
end: callback => fsStream.end(callback)
133+
end: callback => {
134+
// Wait until the write stream finishes.
135+
fsStream.on("finish", () => {
136+
callback();
137+
});
138+
// Tear down the readable trace stream.
139+
trace.destroy();
140+
}
134141
};
135142
}
136143

0 commit comments

Comments
 (0)