Title: Angular 16 migration: TypeError: Cannot read properties of undefined (reading 'getElementById') · Issue #50138 · angular/angular · GitHub
Open Graph Title: Angular 16 migration: TypeError: Cannot read properties of undefined (reading 'getElementById') · Issue #50138 · angular/angular
X Title: Angular 16 migration: TypeError: Cannot read properties of undefined (reading 'getElementById') · Issue #50138 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? Don't known / other Is this a regression? No Description Migrating from angular 15.2.9 to 16.0.0 we encounter the stack trace below when running the universal server (dev & prod buil...
Open Graph Description: Which @angular/* package(s) are the source of the bug? Don't known / other Is this a regression? No Description Migrating from angular 15.2.9 to 16.0.0 we encounter the stack trace below when runni...
X Description: Which @angular/* package(s) are the source of the bug? Don't known / other Is this a regression? No Description Migrating from angular 15.2.9 to 16.0.0 we encounter the stack trace below when r...
Opengraph URL: https://github.com/angular/angular/issues/50138
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Angular 16 migration: TypeError: Cannot read properties of undefined (reading 'getElementById')","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\nDon't known / other\n\n### Is this a regression?\n\nNo\n\n### Description\n\nMigrating from angular 15.2.9 to 16.0.0 we encounter the stack trace below when running the universal server (dev & prod build).\r\nspa dev mode works as expected without any noticeable issues. \r\nFollowing the stack trace it's this piece of code that is encountering an issue:\r\n```js\r\nfunction retrieveTransferredState(doc,appId){const script=doc.getElementById(appId+\"-state\");\r\n```\r\nThe error occurs whether we provide client hydration or not. \r\nWe use TransferState throughout the application to send data from ssr to the client. \r\n\r\nEnvironmentService, that seems to be the root of this error, injects TransferState in the constructor.\r\n\r\nI don't quite know how to drill down on this issue, since this seems to be happening very early in app lifecycle. Any Idea on how to create a reproduction would be highly appreciated. \n\n### Please provide a link to a minimal reproduction of the bug\n\n_No response_\n\n### Please provide the exception or error you saw\n\n```true\nTypeError: Cannot read properties of undefined (reading 'getElementById')\r\n at retrieveTransferredState (/home/marco/FollowAlice/referral/frontend/dist/referral/server/main.js:1:2325653)\r\n at Object.initTransferState [as factory] (/home/marco/FollowAlice/referral/frontend/dist/referral/server/main.js:1:2324438)\r\n at R3Injector.hydrate (/home/marco/FollowAlice/referral/frontend/dist/referral/server/main.js:1:2320111)\r\n at R3Injector.get (/home/marco/FollowAlice/referral/frontend/dist/referral/server/main.js:1:2318370)\r\n at injectInjectorOnly (/home/marco/FollowAlice/referral/frontend/dist/referral/server/main.js:1:2186545)\r\n at Object.ɵɵinject (/home/marco/FollowAlice/referral/frontend/dist/referral/server/main.js:1:2186715)\r\n at Object.EnvironmentService_Factory [as factory] (/home/marco/FollowAlice/referral/frontend/dist/referral/server/main.js:1:27288)\r\n at R3Injector.hydrate (/home/marco/FollowAlice/referral/frontend/dist/referral/server/main.js:1:2320111)\r\n at R3Injector.get (/home/marco/FollowAlice/referral/frontend/dist/referral/server/main.js:1:2318370)\r\n at injectInjectorOnly (/home/marco/FollowAlice/referral/frontend/dist/referral/server/main.js:1:2186545)\n```\n\n\n### Please provide the environment you discovered this bug in (run `ng version`)\n\n```true\nAngular CLI: 16.0.0\r\nNode: 18.16.0\r\nPackage Manager: npm 9.5.1\r\nOS: linux x64\r\n\r\nAngular: 16.0.0\r\n... animations, cdk, cli, common, compiler, compiler-cli, core\r\n... forms, language-service, material, material-luxon-adapter\r\n... platform-browser, platform-browser-dynamic, platform-server\r\n... router, service-worker, youtube-player\r\n\r\nPackage Version\r\n---------------------------------------------------------\r\n@angular-devkit/architect 0.1600.0\r\n@angular-devkit/build-angular 16.0.0\r\n@angular-devkit/core 16.0.0\r\n@angular-devkit/schematics 16.0.0\r\n@nguniversal/builders 16.0.0\r\n@nguniversal/express-engine 16.0.0\r\n@schematics/angular 16.0.0\r\ntypescript 4.9.5\n```\n\n\n### Anything else?\n\n_No response_","author":{"url":"https://github.com/MarcoGlauser","@type":"Person","name":"MarcoGlauser"},"datePublished":"2023-05-04T06:50:07Z","url":"https://github.com/angular/angular/issues/50138"}
| 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:564a7262-6dd5-bec8-b1c5-3d5f75d3ff88 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CE02:3D8CBB:192767B:212B046:6B013FE3 |
| html-safe-nonce | f8e9426aa5adc52736b8accc1833e84b65b61d2c7c7690ada4009baf2fa37b93 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRTAyOjNEOENCQjoxOTI3NjdCOjIxMkIwNDY6NkIwMTNGRTMiLCJ2aXNpdG9yX2lkIjoiODMyODczNzU4MzYxODE0NjI3NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7cafb6787ba591de962676d4a3ba856f1f23a5469a8b6111ef000a762fc5b8f6 |
| hovercard-subject-tag | issue:1695363636 |
| 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/50138/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3913df6edc358a70ab5d4378cb47275e2c4210e24eae51c3cdcdf8bce04ba595/angular/angular/issues/50138 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3913df6edc358a70ab5d4378cb47275e2c4210e24eae51c3cdcdf8bce04ba595/angular/angular/issues/50138 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? Don't known / other Is this a regression? No Description Migrating from angular 15.2.9 to 16.0.0 we encounter the stack trace below when runni... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MarcoGlauser |
| 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