Comments (6)
hmm, you're using async/promise which I haven't tried at all. It could be a race condition where the end
is called and stream closed before your promises have resolved. Try moving the line https://github.com/miralemd/qlik-sse/blob/master/lib/index.js#L29 last into your own function, or test write
without any use of async await.
from qlik-sse.
As @miralemd suggested, when using await the request.end() will get called too early. I resolved the issue for myself by adding an async property to the function config that drives a conditional request.end(). https://github.com/RobWunderlich/qlik-sse/commit/be4bc04ab3ca655bed5f9a2f0c76d5ee054d87eb
@miralemd do you want to accept a PR for this? Or is this too specialized?
from qlik-sse.
fixed by 233e014
from qlik-sse.
@RobWunderlich & @miralemd Thanks for the update. My code still does not seem to want to handle using async. Here is a super easy example which still has request.end() calling too early. Any ideas?
function Test(request) {
function waitUntil(i) {
return new Promise(function(resolve, reject){
setTimeout(() => {
resolve(i);
}, 500);
});
}
request.on('data', async function (bundle) {
console.log('data');
let list = [];
for(let i = 0; i < 10; i++) {
console.log(i);
let resp = await waitUntil(i);
list.push(resp);
}
console.log('writing...');
request.write({ "rows": [{ "duals": [{ "strData": list.toString() }] }] });
});
}
from qlik-sse.
@rileymd88 The async detection expects your primary function to be marked async. So make it "async function Test(request)"
from qlik-sse.
@RobWunderlich Ahh ok that worked! I had to also adjust my code at the end and write request.end()
after request.write(...)
from qlik-sse.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qlik-sse.