<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Problem using 'callback' form of 'connect', JavaScript External Environment in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/problem-using-callback-form-of-connect-javascript-external-environment/qaa-p/13824764#M4855607</link>
    <description>&lt;P&gt;I should have mentioned that I'm running nodejs 0.10.40 - waiting for the update to the SA17 Developer Edition for node 4+ support.&lt;/P&gt;</description>
    <pubDate>Thu, 11 Feb 2016 20:25:28 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2016-02-11T20:25:28Z</dc:date>
    <item>
      <title>Problem using 'callback' form of 'connect', JavaScript External Environment</title>
      <link>https://community.sap.com/t5/technology-q-a/problem-using-callback-form-of-connect-javascript-external-environment/qaq-p/13824762</link>
      <description>&lt;P&gt;I'm encountering a problem using the 'callback' form of 'connect' in the JavaScript External Environment.&lt;/P&gt;
&lt;P&gt;The problem is that the callback code doesn't seem to be executed.  If I use the synchronous version of 'connect', things work as expected.&lt;/P&gt;
&lt;P&gt;I have greated a github gist at (&lt;A href="https://gist.github.com/twilkinson/00748d66bef5fff91852" target="_blank"&gt;https://gist.github.com/twilkinson/00748d66bef5fff91852&lt;/A&gt;) that illustrates the problem.&lt;/P&gt;
&lt;P&gt;There are 2 files:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;First copy &lt;EM&gt;testA.js&lt;/EM&gt; to &lt;EM&gt;C:\\Temp\\testA.js&lt;/EM&gt;.&lt;/LI&gt;
&lt;LI&gt;Then using ISQL, connect to the 'SQL Anywhere 17 Demo' database and execute &lt;EM&gt;testA.sql&lt;/EM&gt;.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;You can see the output in *C:\\Temp\\tests.log".&lt;/P&gt;
&lt;P&gt;All that shows in &lt;EM&gt;tests.log&lt;/EM&gt; are the lines
&lt;/P&gt;&lt;PRE&gt;start of test1A
end of test1A
&lt;/PRE&gt;
where I would expect to also see the first 10 lines of the &lt;EM&gt;Customers&lt;/EM&gt; table.&lt;P&gt;&lt;/P&gt;
&lt;P&gt;It is acting as if the script is terminated without waiting for the asynchronous code to complete.  If I run similar code under nodejs directly, it behaves as I would expect with the first 10 lines of the &lt;EM&gt;Customer&lt;/EM&gt; table showing up in the output file.&lt;/P&gt;
&lt;P&gt;This occurs with the latest SA17 Developer Edition under both Windows and Linux.&lt;/P&gt;
&lt;P&gt;Suggestions?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2016 11:47:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/problem-using-callback-form-of-connect-javascript-external-environment/qaq-p/13824762</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-02-10T11:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Problem using 'callback' form of 'connect', JavaScript External Environment</title>
      <link>https://community.sap.com/t5/technology-q-a/problem-using-callback-form-of-connect-javascript-external-environment/qaa-p/13824763#M4855606</link>
      <description>&lt;P&gt;Which node.js version are your using.
A coworker of mind could not reproduce your other issue with the latest node.js (5.6.0) where I was using nodejs (4.3.0). &lt;/P&gt;
&lt;P&gt;Maybe this is a pure NodeJS version issue.  Have you tried it wih the newer NodeJS downloads available?&lt;/P&gt;
&lt;P&gt;FWIW I can reproduce this with v4.3.0 and it appears with that version, code executed within the body of your callback function will not run with that. (Request logging at the server show no query is submitted)  Extracting the Prepare and Execute operations from that exception handling scope, and placing it back out to the same scope as the connect does work so that tends to confirm this may be a NodeJS runtime issue.&lt;/P&gt;
&lt;P&gt;Hopefully this issue will also be resolved with V5.6.0 or something newer.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2016 17:29:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/problem-using-callback-form-of-connect-javascript-external-environment/qaa-p/13824763#M4855606</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-02-11T17:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Problem using 'callback' form of 'connect', JavaScript External Environment</title>
      <link>https://community.sap.com/t5/technology-q-a/problem-using-callback-form-of-connect-javascript-external-environment/qaa-p/13824764#M4855607</link>
      <description>&lt;P&gt;I should have mentioned that I'm running nodejs 0.10.40 - waiting for the update to the SA17 Developer Edition for node 4+ support.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2016 20:25:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/problem-using-callback-form-of-connect-javascript-external-environment/qaa-p/13824764#M4855607</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-02-11T20:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: Problem using 'callback' form of 'connect', JavaScript External Environment</title>
      <link>https://community.sap.com/t5/technology-q-a/problem-using-callback-form-of-connect-javascript-external-environment/qaa-p/13824765#M4855608</link>
      <description>&lt;P&gt;FYI, I just tried this under Linux (Ubuntu 14.04) with SA17 build 1358 and node v5.6.0. Unfortunately, I still get the behaviour described in my initial post.&lt;/P&gt;
&lt;P&gt;If I run substantially the same code (see testA2.js at &lt;A href="https://gist.github.com/twilkinson/00748d66bef5fff91852"&gt;https://gist.github.com/twilkinson/00748d66bef5fff91852&lt;/A&gt; ) from the linux command line:
&lt;/P&gt;&lt;PRE&gt;node testA-2.js
&lt;/PRE&gt;
it performs as you would expect, writing the database SELECT results to the file.&lt;P&gt;&lt;/P&gt;
&lt;P&gt;It looks to me that for some reason, NodeJS terminates early when called from SA17, and doesn't wait for it's event loop to complete.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Feb 2016 22:46:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/problem-using-callback-form-of-connect-javascript-external-environment/qaa-p/13824765#M4855608</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-02-21T22:46:20Z</dc:date>
    </item>
  </channel>
</rss>

