Skip to content

[FSMCPB-167858] Extend refresh-token samples with ERROR event handling#148

Open
VGio wants to merge 1 commit into
mainfrom
FSMCPB-167858
Open

[FSMCPB-167858] Extend refresh-token samples with ERROR event handling#148
VGio wants to merge 1 commit into
mainfrom
FSMCPB-167858

Conversation

@VGio

@VGio VGio commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds SHELL_EVENTS.ERROR handling to all three refresh-token samples (JavaScript, TypeScript, SAP UI5) as required by the fsm-shell documentation
  • Each sample now demonstrates the three mandatory error-handling requirements:
    1. User notification — error messages are surfaced to the user via a visible warning area
    2. Retry delay — waits 5 seconds before re-emitting REQUIRE_AUTHENTICATION to avoid hammering the Shell
    3. Retry limit — stops after 3 retries with a "please reload" message, preventing excessive API calls that could result in extension deactivation

Changes

All three samples (shell-sdk.service.js/ts)

  • Register SHELL_EVENTS.ERROR listener in init()
  • Add errorSubject (BehaviorSubject) and subscribeToError() method

JS + TS samples (index.js / index.ts)

  • Subscribe to subscribeToError() and display the message in a #error-info element
  • Add amber warning styling (.error-message) to CSS
  • Add #error-info div to HTML

UI5 sample (View1.controller.ts)

  • Subscribe to subscribeToError() and bind the message to the existing /errorMessage model property

Tests

  • Add Vitest unit tests (5 tests each) to the JS and TS samples covering: error emission, retry count messages, MAX_RETRIES cap, retry delay, and unsubscribe
  • Add vitest dev dependency and "test" script to both package.json files

Test plan

  • npm test passes in refresh-token-sample-js (5/5)
  • npm test passes in refresh-token-sample-ts (5/5)
  • npx tsc --noEmit passes in refresh-token-sample-ts
  • npm run ts-typecheck passes in refresh-token-sample-ui5

Closes FSMCPB-167858

Add SHELL_EVENTS.ERROR handler to all three refresh-token samples (JS,
TypeScript, UI5) as required by the fsm-shell documentation: notify the
user on error, wait before retrying, and stop after MAX_RETRIES (3) to
avoid excessive API calls that could result in extension deactivation.

Changes per sample:
- shell-sdk.service: subscribe to SHELL_EVENTS.ERROR in init(), emit
  error messages via a new errorSubject (BehaviorSubject), retry
  REQUIRE_AUTHENTICATION with a 5s delay, cap at 3 retries
- shell-sdk.service: expose subscribeToError() for consumers
- index.js / index.ts / View1.controller.ts: subscribe to error stream
  and display the message to the user
- index.html (JS + TS): add #error-info element for error display
- styles.css (JS + TS): add .error-message styling
- Add Vitest unit tests for the error handling logic (JS + TS samples);
  add vitest dev dependency and "test" script to both package.json files
@cla-assistant

cla-assistant Bot commented Jun 26, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant