Title: application builder: strange behavior of PLATFORM_ID · Issue #26148 · angular/angular-cli · GitHub
Open Graph Title: application builder: strange behavior of PLATFORM_ID · Issue #26148 · angular/angular-cli
X Title: application builder: strange behavior of PLATFORM_ID · Issue #26148 · angular/angular-cli
Description: Command serve Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description Hi. With enabled ssr, dev server starts to serve ssr-ed applic...
Open Graph Description: Command serve Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description Hi. With enabled ssr, ...
X Description: Command serve Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description Hi. With enabled ssr, ...
Opengraph URL: https://github.com/angular/angular-cli/issues/26148
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"application builder: strange behavior of PLATFORM_ID","articleBody":"### Command\n\nserve\n\n### Is this a regression?\n\n- [X] Yes, this behavior used to work in the previous version\n\n### The previous version in which this bug was not present was\n\n_No response_\n\n### Description\n\nHi.\r\nWith enabled ssr, dev server starts to serve ssr-ed application. With this setup, PLATFORM_ID is always browser, while it actually runs in server environment.\r\nThis leads to non-working hydration because of setTimeout() calls, which must be called only in browser env.\r\nHow should i write browser-only or server-only logic now? What is the way?\r\n\r\nTake a look at this example, which leads to hydration errors: \r\n\r\n```\r\nconstructor() {\r\n if(isPlatformServer(inject(PLATFORM_ID))) {\r\n return;\r\n }\r\n\r\n console.log('i am browser');\r\n\r\n setTimeout(() => console.log('hi from browser'), 11000);\r\n }\r\n```\n\n### Minimal Reproduction\n\nhttps://github.com/zip-fa/ng17-ssr-bug\n\n### Exception or Error\n\n```text\ncore.mjs:28900 NG0506: Angular hydration expected the ApplicationRef.isStable() to emit `true`, but it didn't happen within 10000ms. Angular hydration logic depends on the application becoming stable as a signal to complete hydration process\n```\n\n\n### Your Environment\n\n```text\nAngular CLI: 17.0.0-rc.1\r\nNode: 18.18.1\r\nPackage Manager: npm 9.8.1\r\nOS: win32 x64\r\n\r\nAngular: 17.0.0-rc.1\r\n... animations, cli, common, compiler, compiler-cli, core, forms\r\n... platform-browser, platform-browser-dynamic, platform-server\r\n... router, ssr\r\n\r\nPackage Version\r\n---------------------------------------------------------\r\n@angular-devkit/architect 0.1700.0-rc.1\r\n@angular-devkit/build-angular 17.0.0-rc.1\r\n@angular-devkit/core 17.0.0-rc.1\r\n@angular-devkit/schematics 17.0.0-rc.1\r\n@schematics/angular 17.0.0-rc.1\r\nrxjs 7.8.1\r\ntypescript 5.2.2\r\nzone.js 0.14.1\n```\n\n\n### Anything else relevant?\n\n_No response_","author":{"url":"https://github.com/zip-fa","@type":"Person","name":"zip-fa"},"datePublished":"2023-10-26T17:29:04Z","url":"https://github.com/angular/angular-cli/issues/26148"}
| 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:bedafe0e-1450-964b-6768-af76cb764e6a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9B18:12EFD7:2D3950A:3A482E2:6B040DF4 |
| html-safe-nonce | 85a13b394ec9abf4a9f76f1d3bd713a8f41b5f0b0dec91f90a1a0692119dda2a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QjE4OjEyRUZENzoyRDM5NTBBOjNBNDgyRTI6NkIwNDBERjQiLCJ2aXNpdG9yX2lkIjoiMTcxNDU4ODcxNjMwMTAyODg1MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2e468a85afe9fa6afbf5fd029484a735b85ad80775a4c390ae02501e99567967 |
| hovercard-subject-tag | issue:1964029026 |
| 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-cli/26148/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dbb443812fb8bc5b33c3f25aeca091a716eb46793d6ddad9b623b3a68edb71e3/angular/angular-cli/issues/26148 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dbb443812fb8bc5b33c3f25aeca091a716eb46793d6ddad9b623b3a68edb71e3/angular/angular-cli/issues/26148 |
| og:image:alt | Command serve Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description Hi. With enabled ssr, ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zip-fa |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width