I'm encountering a problem using the 'callback' form of 'connect' in the JavaScript External Environment.

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.

I have greated a github gist at (https://gist.github.com/twilkinson/00748d66bef5fff91852) that illustrates the problem.

There are 2 files:

  1. First copy testA.js to C:\Temp\testA.js.
  2. Then using ISQL, connect to the 'SQL Anywhere 17 Demo' database and execute testA.sql.

You can see the output in *C:\Temp\tests.log".

All that shows in tests.log are the lines

start of test1A
end of test1A
where I would expect to also see the first 10 lines of the Customers table.

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 Customer table showing up in the output file.

This occurs with the latest SA17 Developer Edition under both Windows and Linux.

Suggestions?

Thanks,

asked 10 Feb '16, 11:46

Terry%20Wilkinson's gravatar image

Terry Wilkinson
746303548
accept rate: 25%

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).

Maybe this is a pure NodeJS version issue. Have you tried it wih the newer NodeJS downloads available?

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.

Hopefully this issue will also be resolved with V5.6.0 or something newer.

(11 Feb '16, 17:29) Nick Elson S...

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.

(11 Feb '16, 20:25) Terry Wilkinson

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.

If I run substantially the same code (see testA2.js at https://gist.github.com/twilkinson/00748d66bef5fff91852 ) from the linux command line:

node testA-2.js

it performs as you would expect, writing the database SELECT results to the file.

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.

(21 Feb '16, 22:46) Terry Wilkinson
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×240
×68
×49
×24
×21

question asked: 10 Feb '16, 11:46

question was seen: 4,372 times

last updated: 21 Feb '16, 23:07