Skip to content

Commit 24b046e

Browse files
authored
Merge pull request webpack#6415 from samccone/sjs/fix-last-event
Manually exclude internal tap of plugin.
2 parents c963e3d + 88cdf4b commit 24b046e

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

lib/debug/ProfilingPlugin.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ function createTrace(outPath) {
130130
};
131131
}
132132

133+
const pluginName = "ProfilingPlugin";
134+
133135
class ProfilingPlugin {
134136
// TODO: Add plugin schema validation here since there are options.
135137
constructor(opts) {
@@ -150,7 +152,7 @@ class ProfilingPlugin {
150152
compiler.resolverFactory.hooks[hookName].intercept(makeInterceptorFor("Resolver", tracer)(hookName));
151153
});
152154

153-
compiler.hooks.compilation.tap("ProfilingPlugin", (compilation, {
155+
compiler.hooks.compilation.tap(pluginName, (compilation, {
154156
normalModuleFactory,
155157
contextModuleFactory
156158
}) => {
@@ -163,7 +165,7 @@ class ProfilingPlugin {
163165

164166
// We need to write out the CPU profile when we are all done.
165167
compiler.hooks.done.tap({
166-
name: "ProfilingPlugin",
168+
name: pluginName,
167169
stage: Infinity
168170
}, () => {
169171
tracer.profiler.stopProfiling().then((parsedResults) => {
@@ -356,6 +358,12 @@ const makeNewProfiledTapFn = (hookName, tracer, {
356358
case "sync":
357359
return(...args) => { // eslint-disable-line
358360
const id = ++tracer.counter;
361+
// Do not instrument outself due to the CPU
362+
// profile needing to be the last event in the trace.
363+
if(name === pluginName) {
364+
return fn(...args);
365+
}
366+
359367
tracer.trace.begin({
360368
name,
361369
id,

0 commit comments

Comments
 (0)