Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Angular Schematics - Apply thousands of changes on tree cause error "Maximum call stack size exceeded"

未关闭
#17,851 1 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
angular, typescript
领域
cli, tooling

调研方向

从复现代码中的 createPageComponents 入口点开始,重点查看 rules 数组和 chain(rules),并使用超过 1,000 条 schematics 规则复现失败。结合报告中显示的 RxJS 堆栈跟踪,阅读 Angular Schematics 的执行路径。能够应用大量页面组件更改而不出现 maximum call stack 错误,即表示完成。

由索引模型根据 Issue 内容生成。

描述

area: @angular-devkit/schematics freq1: low severity3: broken type: bug/fix

🐞 Bug report

Description

I use Angular Schematics to migrate from AngularJs to Angular. The application is a large one with thousands of page. I try to create a component for each page based on a template. When I try to create the component on a smaller project like 200 pages it's working but when I fall on a large one with more than 1000 pages (1000 schematics rules)

🔬 Minimal Reproduction


export function createPageComponents(options: any): Rule {
    return (tree: Tree, context: SchematicContext) => {
        const logger = context.logger;
        const directory = tree.getDir('my_path/pages');

        const rules: Rule[] = [];
        directory.visit((filePath) => {
            if (!filePath.endsWith('config.ts')) {
                return;
            }

            const dirPath = dirname(filePath);
            const parsedPath = parseName(dirPath, basename(filePath).split('.')[0]);
            options = {
                path: parsedPath.path,
                name: parsedPath.name
            };

            const templateSource = apply(
                url('./files'),
                [
                    applyTemplates({
                        ...strings,
                        ...options
                    }),
                    move(parsedPath.path)
                ]
            );

            const rule = mergeWith(templateSource);

            rules.push(rule);
        });

        return chain(rules);
    };
}

🔥 Exception or Error


    RangeError: Maximum call stack size exceeded
        at Console.warn ()
        at Observable._trySubscribe (my_path\node_modules\rxjs\internal\Observable.js:55:25)
        at Observable.subscribe (my_path\node_modules\rxjs\internal\Observable.js:30:22)
        at MergeMapOperator.call (my_path\node_modules\rxjs\internal\operators\mergeMap.js:39:23)
        at Observable.subscribe (my_path\node_modules\rxjs\internal\Observable.js:25:31)
        at MapOperator.call (my_path\node_modules\rxjs\internal\operators\map.js:32:23)
        at Observable.subscribe (my_path\node_modules\rxjs\internal\Observable.js:25:31)
        at MapToOperator.call (my_path\node_modules\rxjs\internal\operators\mapTo.js:26:23)
        at Observable.subscribe (my_path\node_modules\rxjs\internal\Observable.js:25:31)
        at DefaultIfEmptyOperator.call (my_path\node_modules\rxjs\internal\operators\defaultIfEmpty.js:27:23)

🌍 Your Environment


Angular CLI: 9.1.4
Node: 10.19.0
OS: win32 x64

Angular: 9.1.4
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.901.4
@angular-devkit/build-angular      0.901.4
@angular-devkit/build-ng-packagr   0.901.4
@angular-devkit/build-optimizer    0.901.4
@angular-devkit/build-webpack      0.901.4
@angular-devkit/core               9.1.4
@angular-devkit/schematics         9.1.7
@angular-devkit/schematics-cli     0.901.7
@angular/upgrade                   9.1.9
@ngtools/webpack                   9.1.4
@schematics/angular                9.1.4 (cli-only)
@schematics/schematics             0.901.7
@schematics/update                 0.901.4
ng-packagr                         9.1.3
rxjs                               6.5.5
typescript                         3.8.3
webpack                            4.42.0
主要语言
TypeScript
星标
27k
派生
11.8k
平均合并
16 小时 35 分钟
30 天内合并 PR
176

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

angular/angular-cli 的其他 Issue

查看 angular/angular-cli 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。