Skip to content

Commit

Permalink
fix: prevent from accessing outdated compilation (#8591)
Browse files Browse the repository at this point in the history
  • Loading branch information
SyMind authored Dec 2, 2024
1 parent 9335a8b commit 2d20aba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
3 changes: 1 addition & 2 deletions packages/rspack/src/Compilation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1135,8 +1135,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
}
}
);
},
10
}
))(this);

rebuildModule(m: Module, f: (err: Error, m: Module) => void) {
Expand Down
14 changes: 3 additions & 11 deletions packages/rspack/src/util/MergeCaller.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
type CallFn<D> = (args: D[]) => void;

export default class MergeCaller<D> {
private timer: any = null;
private callArgs: D[] = [];

// add in constructor
private debounceTime: number;
private callFn: CallFn<D>;
constructor(fn: CallFn<D>, debounceTime: number) {
this.debounceTime = debounceTime;
constructor(fn: CallFn<D>) {
this.callFn = fn;
}

private finalCall = () => {
this.timer = null;
const args = this.callArgs;
this.callArgs = [];
this.callFn(args);
};

push(...data: D[]) {
if (this.timer) {
clearTimeout(this.timer);
if (this.callArgs.length === 0) {
queueMicrotask(this.finalCall);
}

this.callArgs.push(...data);

this.timer = setTimeout(this.finalCall, this.debounceTime);
}
}
2 changes: 1 addition & 1 deletion packages/rspack/src/util/fake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function createFakeCompilationDependencies(
getDeps: () => string[],
addDeps: (deps: string[]) => void
) {
const addDepsCaller = new MergeCaller(addDeps, 10);
const addDepsCaller = new MergeCaller(addDeps);
return {
*[Symbol.iterator]() {
const deps = getDeps();
Expand Down

2 comments on commit 2d20aba

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-12-02 5a967f7) Current Change
10000_big_production-mode_disable-minimize + exec 42.8 s ± 1.97 s 42.3 s ± 578 ms -1.09 %
10000_development-mode + exec 1.8 s ± 45 ms 1.81 s ± 40 ms +0.81 %
10000_development-mode_hmr + exec 648 ms ± 5.5 ms 647 ms ± 4 ms -0.17 %
10000_production-mode + exec 2.39 s ± 30 ms 2.4 s ± 25 ms +0.43 %
arco-pro_development-mode + exec 1.73 s ± 82 ms 1.74 s ± 70 ms +0.35 %
arco-pro_development-mode_hmr + exec 426 ms ± 2.5 ms 426 ms ± 2.1 ms +0.12 %
arco-pro_production-mode + exec 3.13 s ± 60 ms 3.1 s ± 67 ms -0.75 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.16 s ± 77 ms 3.13 s ± 42 ms -0.79 %
threejs_development-mode_10x + exec 1.62 s ± 15 ms 1.63 s ± 14 ms +0.18 %
threejs_development-mode_10x_hmr + exec 810 ms ± 8.1 ms 812 ms ± 17 ms +0.23 %
threejs_production-mode_10x + exec 4.94 s ± 37 ms 4.93 s ± 31 ms -0.15 %
10000_big_production-mode_disable-minimize + rss memory 13399 MiB ± 459 MiB 13454 MiB ± 118 MiB +0.41 %
10000_development-mode + rss memory 775 MiB ± 13.2 MiB 788 MiB ± 34.3 MiB +1.71 %
10000_development-mode_hmr + rss memory 2010 MiB ± 398 MiB 2078 MiB ± 364 MiB +3.39 %
10000_production-mode + rss memory 671 MiB ± 27.6 MiB 670 MiB ± 40.9 MiB -0.09 %
arco-pro_development-mode + rss memory 741 MiB ± 47.6 MiB 719 MiB ± 39.1 MiB -2.96 %
arco-pro_development-mode_hmr + rss memory 922 MiB ± 152 MiB 941 MiB ± 68.6 MiB +2.06 %
arco-pro_production-mode + rss memory 878 MiB ± 26.9 MiB 854 MiB ± 49.8 MiB -2.80 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 871 MiB ± 38.5 MiB 861 MiB ± 62.2 MiB -1.15 %
threejs_development-mode_10x + rss memory 830 MiB ± 31.6 MiB 825 MiB ± 49.2 MiB -0.54 %
threejs_development-mode_10x_hmr + rss memory 2115 MiB ± 194 MiB 2118 MiB ± 241 MiB +0.12 %
threejs_production-mode_10x + rss memory 1037 MiB ± 68.4 MiB 1075 MiB ± 22.5 MiB +3.63 %

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs ✅ success
_selftest ✅ success
rsdoctor ✅ success
rspress ✅ success
rslib ❌ failure
rsbuild ✅ success
examples ✅ success
devserver ✅ success
nuxt ✅ success

Please sign in to comment.