Title: ERROR in RangeError: Maximum call stack size exceeded on production build and faulty export on module · Issue #19979 · angular/angular · GitHub
Open Graph Title: ERROR in RangeError: Maximum call stack size exceeded on production build and faulty export on module · Issue #19979 · angular/angular
X Title: ERROR in RangeError: Maximum call stack size exceeded on production build and faulty export on module · Issue #19979 · angular/angular
Description: Moved over from angular/angular-cli#8187, opened by @BartNetJS. Bug Report or Feature Request (mark with an x) - [x] bug report - [ ] feature request Versions. @angular/cli: 1.4.9 node: 8.7.0 os: win32 x64 @angular/animations: 4.4.6 @ang...
Open Graph Description: Moved over from angular/angular-cli#8187, opened by @BartNetJS. Bug Report or Feature Request (mark with an x) - [x] bug report - [ ] feature request Versions. @angular/cli: 1.4.9 node: 8.7.0 os: w...
X Description: Moved over from angular/angular-cli#8187, opened by @BartNetJS. Bug Report or Feature Request (mark with an x) - [x] bug report - [ ] feature request Versions. @angular/cli: 1.4.9 node: 8.7.0 os: w...
Opengraph URL: https://github.com/angular/angular/issues/19979
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ERROR in RangeError: Maximum call stack size exceeded on production build and faulty export on module","articleBody":"Moved over from https://github.com/angular/angular-cli/issues/8187, opened by @BartNetJS.\r\n\r\n---\r\n\r\n### Bug Report or Feature Request (mark with an `x`)\r\n```\r\n- [x] bug report \r\n- [ ] feature request\r\n```\r\n\r\n### Versions.\r\n@angular/cli: 1.4.9\r\nnode: 8.7.0\r\nos: win32 x64\r\n@angular/animations: 4.4.6\r\n@angular/common: 4.4.6\r\n@angular/compiler: 4.4.6\r\n@angular/core: 4.4.6\r\n@angular/forms: 4.4.6\r\n@angular/http: 4.4.6\r\n@angular/platform-browser: 4.4.6\r\n@angular/platform-browser-dynamic: 4.4.6\r\n@angular/router: 4.4.6\r\n@angular/cli: 1.4.9\r\n@angular/compiler-cli: 4.4.6\r\n@angular/language-service: 4.4.6\r\ntypescript: 2.3.4\r\n\r\n### Repro steps.\r\nCreate a module and export the same module in the export tag (this is the fault)\r\n```\r\n@NgModule({\r\n imports: [CommonModule],\r\n exports: [ MyFaultyModule ],\r\n declarations: [MyFaultyComponent],\r\n providers: [],\r\n})\r\nexport class MyFaultyModule { }\r\n```\r\nBuild a production build:\r\nng build --prod\r\n\r\n### The log given by the failure.\r\nERROR in RangeError: Maximum call stack size exceeded\r\n at StaticReflector.annotations (PathRemovedForDemo\\node_modules\\@angular\\compiler\\bundles\\compiler.umd.js:1:1)\r\n at NgModuleResolver.resolve (PathRemovedForDemo\\node_modules\\@angular\\compiler\\bundles\\compiler.umd.js:14750:70)\r\n at CompileMetadataResolver.getNgModuleMetadata (PathRemovedForDemo\\node_modules\\@angular\\compiler\\bundles\\compiler.umd.js:15402:60)\r\n at CompileMetadataResolver.getNgModuleSummary (PathRemovedForDemo\\node_modules\\@angular\\compiler\\bundles\\compiler.umd.js:15358:52)\r\n at PathRemovedForDemo\\node_modules\\@angular\\compiler\\bundles\\compiler.umd.js:15450:68\r\n at Array.forEach (\u003canonymous>)\r\n at CompileMetadataResolver.getNgModuleMetadata (PathRemovedForDemo\\node_modules\\@angular\\compiler\\bundles\\compiler.umd.js:15445:49)\r\n at CompileMetadataResolver.getNgModuleSummary (PathRemovedForDemo\\node_modules\\@angular\\compiler\\bundles\\compiler.umd.js:15358:52)\r\n at PathRemovedForDemo\\node_modules\\@angular\\compiler\\bundles\\compiler.umd.js:15450:68\r\n at Array.forEach (\u003canonymous>)\r\n at CompileMetadataResolver.getNgModuleMetadata (PathRemovedForDemo\\node_modules\\@angular\\compiler\\bundles\\compiler.umd.js:15445:49)\r\n at CompileMetadataResolver.getNgModuleSummary (PathRemovedForDemo\\node_modules\\@angular\\compiler\\bundles\\compiler.umd.js:15358:52)\r\n at PathRemovedForDemo\\node_modules\\@angular\\compiler\\bundles\\compiler.umd.js:15450:68\r\n at Array.forEach (\u003canonymous>)\r\n at CompileMetadataResolver.getNgModuleMetadata (PathRemovedForDemo\\node_modules\\@angular\\compiler\\bundles\\compiler.umd.js:15445:49)\r\n at CompileMetadataResolver.getNgModuleSummary (PathRemovedForDemo\\node_modules\\@angular\\compiler\\bundles\\compiler.umd.js:15358:52)\r\n\r\n### Desired functionality.\r\nThe ng cli should detect this fault and report the module that causes the call stack exception\r\n\r\n### Mention any other details that might be useful.\r\nThe issue can be found in **compile.umd.js**:\r\nfunction: **CompileMetadataResolver.prototype.getNgModuleMetadata **\r\nOn the code:\r\n\r\n```\r\n if (meta.exports) {\r\n flattenAndDedupeArray(meta.exports).forEach(function (exportedType) {\r\n if (!isValidType(exportedType)) {\r\n _this._reportError(syntaxError(\"Unexpected value '\" + stringifyType(exportedType) + \"' exported by the module '\" + stringifyType(moduleType) + \"'\"), moduleType);\r\n return;\r\n }\r\n var /** @type {?} */ exportedModuleSummary = _this.getNgModuleSummary(exportedType); if (exportedModuleSummary) {\r\n exportedModules.push(exportedModuleSummary);\r\n }\r\n else {\r\n exportedNonModuleIdentifiers.push(_this._getIdentifierMetadata(exportedType));\r\n }\r\n });\r\n }\r\n```\r\n\r\n**var exportedModuleSummary = _this.getNgModuleSummary(exportedType); \r\n=> this cause the recursion and endless loop because 'getNgModuleMetadata ' is called again for the same module** \r\n\r\nSo my suggestion is watch how deep the recusion is going, and for example start logging warnings when reached 5 nested call.\r\nSomething like this:\r\n\r\n```\r\nCompileMetadataResolver.prototype.getNgModuleMetadata = function (moduleType, throwIfNotFound, nested = 0) {\r\n nested++;\r\n if(nested > 4) console.warn(´nested module {moduleType.name} (level: ${nested})´)\r\n```\r\nof course function calling **getNgModuleMetadata** should be modified to.\r\n\r\nCan someone on the core cli team confirm this is a good approach?\r\n\r\nAnother approach is of course checking for the module name that is calling it self, but suppose you have something like this moduleX=>export moduleY=>exportmoduleX...\r\n\r\nIf so, I will create a pull request","author":{"url":"https://github.com/filipesilva","@type":"Person","name":"filipesilva"},"datePublished":"2017-10-27T13:30:05Z","url":"https://github.com/angular/angular/issues/19979"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ce3cd98b-99cb-62a4-0c66-aebd9fa5545b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BF1E:317608:1A53058:2156AF9:6B01482A |
| html-safe-nonce | d206b3812c450113c39e0fad8e41ce2671efcefeea05290da41de8ccc8d59846 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRjFFOjMxNzYwODoxQTUzMDU4OjIxNTZBRjk6NkIwMTQ4MkEiLCJ2aXNpdG9yX2lkIjoiMzAyNDgzNzEwNjM0MzE2ODA0MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2932a190b0865b3b6a51d388f1d32521b8fe14ddcb5a9da35d4f4ecbded229cb |
| hovercard-subject-tag | issue:269107632 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/19979/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8c642dd6fd3af3ea25cd5a656d94fe42f4ae9c7b0e79dbbabf8e479ec0f11859/angular/angular/issues/19979 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8c642dd6fd3af3ea25cd5a656d94fe42f4ae9c7b0e79dbbabf8e479ec0f11859/angular/angular/issues/19979 |
| og:image:alt | Moved over from angular/angular-cli#8187, opened by @BartNetJS. Bug Report or Feature Request (mark with an x) - [x] bug report - [ ] feature request Versions. @angular/cli: 1.4.9 node: 8.7.0 os: w... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | filipesilva |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width