Handle Comet Server Push Requests in a Modern Way and Allow Easier Override

XMLWordPrintable

    • Type: New Feature
    • Resolution: Unresolved
    • Priority: Normal
    • None
    • Affects Version/s: 10.2.1
    • Component/s: None
    • None

      User Story

      As a ZK app developer using comet server push, I want the XMLHttpRequest event handling to use modern APIs and be easily extensible. So that I can handle different request states (timeouts, network errors, etc.) without complex override patterns

      Acceptance Criteria

      1. Modern XMLHttpRequest Event Handling
        • GIVEN a comet server push request is initiated
        • WHEN the request completes, times out, errors, or is aborted
        • THEN dedicated event handlers should be called instead of generic onreadystatechange
            // Proposed modern approach
            req.onload = this._onLoad.bind(this);
            req.onerror = this._onError.bind(this);
            req.ontimeout = this._onTimeout.bind(this);
            req.onabort = this._onAbort.bind(this);
          
      2. Extensible Event Handler Architecture
        • GIVEN developers need custom request handling behavior
        • WHEN they want to override specific event types
        • THEN they should be able to override single funciton
      3. Event Classification and Context
        • GIVEN different types of request events occur
        • WHEN handlers are invoked
        • THEN they should receive rich context about the event type and state
      4. Backward Compatibility
        • GIVEN existing ZK applications use the current API
        • WHEN this feature is implemented
        • THEN existing behavior should remain unchanged by default
        • AND new behavior should be opt-in via configuration
      5. Put XMLHttpRequestino creation in an independent function
        • allow to be overridden

      Details

      • The current SPush implementation in /zkcml/zkex/src/main/resources/web/js/zkex/cmsp/serverpush.ts uses legacy XMLHttpRequest event handling:
        // Current (legacy approach)
        req.onreadystatechange = this._onRespReady.bind(this);
        req.onabort = this._retry.bind(this) as never;
        // Missing: ontimeout, onerror handlers
      

      This causes several issues:

      • Expected timeouts are treated as errors, incrementing fail counters
      • Network errors and timeouts can't be distinguished
      • Developers need complex zk.override() patterns to customize behavior
      • Mixed old/new event paradigms create inconsistent behavior

            Assignee:
            Unassigned
            Reporter:
            hawk
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: