Commit 2a8a531
JCU/fix(ssr): stop the blank flash on load and on reload (#1493)
* JCU/fix(ssr): serve a reloaded comcol search tab from the page it belongs to
Opening a community or collection moves the address bar to its /search tab, and #1424 put that
path in ssr.excludePathPatterns. Reloading there returned the 1113-byte CSR shell, so the visitor
got a white page for 0.6s on a fast desktop and up to 3.4s on a slow one.
Both URLs render ComcolSearchSectionComponent and the comcol page itself is server-rendered, so a
GET for the bare tab URL is redirected to it; the client puts /search back in the address bar as
it did before. A URL carrying a query is left alone, which is the point of the exclusion: what
saturated SSR on mendelu (#1402) is the Discovery facet parameter space, and those URLs all carry
f. parameters. The redirect turns itself off if the tab stops being excluded, if the comcol page
ever becomes excluded, or if defaultBrowseTab is not the search tab, since then the comcol page is
a different view and the reload would land somewhere the visitor did not ask for.
Doing this in ComcolPageBrowseByComponent instead, by not redirecting to the default tab, looks
tidier and does not work: getSearchLink() returns currentPath(router) for an in-place search, so
every facet link would move to /collections/<uuid>?f. , which no pattern matches, and the trap
reopens.
Also fixes the robots.txt comment claiming the SSR-side rule is not configured, wrong since #1424.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* JCU/fix(ssr): keep the rendered page on screen while Angular rebuilds it
Every server-rendered route flashes white on load and on reload: the browser paints the SSR page,
then clears <ds-app> and renders the whole tree again. provideClientHydration() is registered in
the browser config only, never in the server one, so platform-server emits no hydration
annotations (ngh= count is 0 on every DSpace 9 instance) and Angular calls selectRootElement with
preserveContent false. Upstream issue: DSpace#3867.
index.html paints a detached clone of the server-rendered view on top and drops it once Angular has
detached the node it cloned, #main-content is visible again and the DOM has been quiet for 600ms.
Waiting for that detach matters: keyed on quiet alone the clone leaves during the long pause before
Angular starts, and the wipe happens in plain sight. Cloning rather than moving means the DOM
Angular works on is untouched, and the clone is built after the first paint so it does not delay it.
On a route in ssr.excludePathPatterns there is nothing to clone, so a spinner fills the gap instead
of a white page. It is not held to the same rule: there is no paint to protect, so it goes as soon
as something is behind it. The spinner itself is held back 400ms, so a fast bootstrap never shows one.
Kept self-contained rather than driving the removal from AppComponent, as customer/mendelu does:
measured on a production build, Angular constructs AppComponent around 5s after the script runs,
so that version only ever hit its fallback timer and left the clone up for 15s.
Enabling hydration on the server is not a substitute. Tried and measured: annotations appear, but
hydration claims only ds-app and ds-root before dying on ds-themed-root, because ThemedComponent
builds themed wrappers with ViewContainerRef.createComponent in ngAfterViewInit and then removes
the projected host. The app then renders nothing at all.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 28388bb commit 2a8a531
3 files changed
Lines changed: 207 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
224 | 254 | | |
225 | 255 | | |
226 | 256 | | |
227 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
228 | 263 | | |
229 | 264 | | |
230 | 265 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
10 | 51 | | |
11 | 52 | | |
12 | 53 | | |
13 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
14 | 185 | | |
15 | 186 | | |
16 | 187 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
0 commit comments