Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-26961

Windows: Save HttpClient instance until callback is fired

    Details

    • Type: Story
    • Status: Closed
    • Priority: None
    • Resolution: Done
    • Affects Version/s: Release 8.0.0
    • Fix Version/s: Release 8.1.0
    • Component/s: Windows
    • Labels:
      None
    • Story Points:
      8
    • Sprint:
      2019 Sprint 8

      Description

      Currently HttpClient may be garbege-collected before its callback is fired under some circumstances if you don't save HttpClient instance from garbage collector. In that case application crashes. We might want to save HttpClient instance from garbage collection by protecting its instance until onerror or onload callback is called.

      var win = Ti.UI.createWindow({
          backgroundColor: 'green'
      });
       
      win.addEventListener('open', function () {
          var _tmpURL = "https://docs.appcelerator.com/platform/latest/#!/api/"
          var _tmpClient = Ti.Network.createHTTPClient({
              onload: function (e) {
                  alert('Loaded');
              },
              onerror: function (e) {
                  alert("Error:" + e.error);
              },
              timeout: 30000
          });
          _tmpClient.open("GET", _tmpURL);
          _tmpClient.send();
       
          // In this case _tmpClient may be garbage-collected as soon as this function is finished.
          // We could think this as "logical" failure but I think Titanium developers tend to use HttpClient like this.
      });
       
      win.open();
      

        Attachments

          Activity

            People

            • Assignee:
              kiguchi Kota Iguchi
              Reporter:
              kiguchi Kota Iguchi
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Source Code