Skip to content

fix(flow-client): log the init failure hidden by the offline stub - #25731

Merged
Artur- merged 2 commits into
mainfrom
fix/log-swallowed-flow-ui-init-error
Sep 15, 2026
Merged

Artur- merged 2 commits into
mainfrom
fix/log-swallowed-flow-ui-init-error

Conversation

@totally-not-ai

@totally-not-ai totally-not-ai Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Summary

When the Flow UI initialization request fails, the client shows the offline stub and used to throw the real error away. Now it logs that error first, so the HTTP status and response body of the failed request are visible in the browser console.

What changed

Behavior change: the client now writes one console.error message when init fails and it falls back to the offline stub. This affects every user whose app hits a failed init request. Nothing else changes: the fallback to the offline stub and the CONNECTION_LOST state work exactly as before, and the already-offline path stays silent. Tests that assert on console.error output could see one extra message.

Why this matters: the FlowUiInitializationError carries the status and body of the failed request, but it was caught and dropped. The only symptom left was a missing UI. In an app without @PWA the stub has no route, so the page just says Couldn't find route for 'offline-stub.html' and the real server error is nowhere to be seen.

In the tests, the two offline stub cases stub console.error, and a sinon.restore() was added to the existing afterEach hook. All spies and stubs in the file use the default sandbox, so that one call restores them all and keeps a failing case from leaking a replaced console.error into later cases.

Test summary

# Status What the test verifies Why it matters
1 When init fails with HTTP 500, the offline stub is shown and console.error is called exactly once with an Error whose message contains 500 and the response body unable to connect This is the fix. If it regressed, a server-side init failure would again be invisible and look like a missing UI
2 When navigation starts while already offline, the stub is shown and console.error is never called Keeps the log meaningful: a message means a real init failure, not a normal offline navigation
3 The stub still loads ./offline-stub.html, hides the loading indicator, and onBeforeEnter / onBeforeLeave still return undefined Confirms the logging did not change the existing fallback behavior
  • Flow.should show stub when navigating to server view and Flow initialization fails due to network error — rows 1, 3
  • Flow.should show stub when navigating to server view offline — rows 2, 3
  • Flow.afterEach (hook, not a test) — adds sinon.restore() so a stubbed console.error cannot leak into later cases

Left untested on purpose: the exact wording of the log message, since only the attached error object carries information a developer can act on.

When the UI initialization request fails, the client assumes the
connection was lost and replaces the view with the offline stub. The
FlowUiInitializationError carries the HTTP status and body of the failed
request, but it was caught and discarded, so the only symptom left was a
missing UI. In an application without @pwa the stub resolves to no
route, so the page ends up showing "Couldn't find route for
'offline-stub.html'" and the server error is nowhere to be found.
The two offline stub cases wrapped route.action() in try/finally only so
a throwing case could not leak the replaced console.error into the cases
that follow. One sinon.restore() in the existing hook covers every spy
and stub in the file, which all use the default sandbox.
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 1 452 files  ±0   1 536 suites  ±0   1h 34m 36s ⏱️ - 6m 10s
11 900 tests ±0  11 832 ✅ ±0  68 💤 ±0  0 ❌ ±0 
12 218 runs  ±0  12 150 ✅ ±0  68 💤 ±0  0 ❌ ±0 

Results for commit 1e522cf. ± Comparison against base commit a219046.

@Artur-
Artur- added this pull request to the merge queue Sep 15, 2026
Merged via the queue into main with commit 4dd46bc Sep 15, 2026
89 of 91 checks passed
@Artur-
Artur- deleted the fix/log-swallowed-flow-ui-init-error branch September 15, 2026 15:43
vaadin-bot added a commit that referenced this pull request Sep 15, 2026
…5731) (CP: 25.3) (#25733)

This PR cherry-picks changes from the original PR #25731 to branch 25.3.
---
#### Original PR description
> ## Summary
> When the Flow UI initialization request fails, the client shows the
offline stub and used to throw the real error away. Now it logs that
error first, so the HTTP status and response body of the failed request
are visible in the browser console.
> 
> ## What changed
> **Behavior change:** the client now writes one `console.error` message
when init fails and it falls back to the offline stub. This affects
every user whose app hits a failed init request. Nothing else changes:
the fallback to the offline stub and the `CONNECTION_LOST` state work
exactly as before, and the already-offline path stays silent. Tests that
assert on `console.error` output could see one extra message.
> 
> Why this matters: the `FlowUiInitializationError` carries the status
and body of the failed request, but it was caught and dropped. The only
symptom left was a missing UI. In an app without `@PWA` the stub has no
route, so the page just says `Couldn't find route for
'offline-stub.html'` and the real server error is nowhere to be seen.
> 
> In the tests, the two offline stub cases stub `console.error`, and a
`sinon.restore()` was added to the existing `afterEach` hook. All spies
and stubs in the file use the default sandbox, so that one call restores
them all and keeps a failing case from leaking a replaced
`console.error` into later cases.
> 
> ## Test summary
> 
> | # | Status | What the test verifies | Why it matters |
> |---|--------|------------------------|----------------|
> | 1 | ✅ | When init fails with HTTP 500, the offline stub is shown
**and** `console.error` is called exactly once with an `Error` whose
message contains `500` and the response body `unable to connect` | This
is the fix. If it regressed, a server-side init failure would again be
invisible and look like a missing UI |
> | 2 | ✅ | When navigation starts while already offline, the stub is
shown and `console.error` is never called | Keeps the log meaningful: a
message means a real init failure, not a normal offline navigation |
> | 3 | ✅ | The stub still loads `./offline-stub.html`, hides the
loading indicator, and `onBeforeEnter` / `onBeforeLeave` still return
`undefined` | Confirms the logging did not change the existing fallback
behavior |
> 
> - `Flow.should show stub when navigating to server view and Flow
initialization fails due to network error` — rows 1, 3
> - `Flow.should show stub when navigating to server view offline` —
rows 2, 3
> - `Flow.afterEach` (hook, not a test) — adds `sinon.restore()` so a
stubbed `console.error` cannot leak into later cases
> 
> Left untested on purpose: the exact wording of the log message, since
only the attached error object carries information a developer can act
on.

Co-authored-by: totally-not-ai[bot] <290682512+totally-not-ai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants