Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abort query request #365

Closed
pavelvlasov opened this issue Dec 2, 2015 · 5 comments · Fixed by #370 or #430
Closed

Abort query request #365

pavelvlasov opened this issue Dec 2, 2015 · 5 comments · Fixed by #370 or #430

Comments

@pavelvlasov
Copy link

Is there any way to abort request after keenClient.run(...)?

@dustinlarimer
Copy link
Contributor

@pavelvlasov thanks for submitting this question, and apologies for the late reply. Would you mind expanding on this a bit? In which circumstances would need to abort a request? Just curious-

@pavelvlasov
Copy link
Author

@dustinlarimer sorry for a late response. We have chart with several lines and timeframe selector. I just want to abort query requests if user need another timeframe, or timeframe was selected by mistake. Because sometimes queries take a lot of time and it doesn't make sense to wait, if another interval was selected.

@dustinlarimer
Copy link
Contributor

@pavelvlasov thanks for the reply! Copying my response from this comment, perhaps this will work for you as well? #370 (comment)

The request object that client.run() returns includes a basic event emitter, and emits a "complete" event when a query is returned. I wonder if this could help right now, as-is:

var req = client.run(query);

// Subscribe
req.on('complete', handleResponse);

// Unsubscribe
req.off('complete');

Do you think that might do the trick? This won't abort the XHR request, but may prevent the error that's holding you up.

Also, give keen-analysis.js a look. This is a new SDK currently being developed, but is stable enough to use. It runs on the Bluebird promise library, making use of the .cancel() method for aborting XHR requests.

@pavelvlasov
Copy link
Author

thanks @dustinlarimer! keen-analysis looks like a good option.

Solution from your comment won't work for me, because I need to abort XHR. We're performing 3-4 concurrent requests to keen for each chart, so it can slow down the UI a lot.

Aren't you going to add abort feature soon? Because we're widely using keen-js in our project and migrating to keen-analysis will take a lot of time.

@dustinlarimer
Copy link
Contributor

@pavelvlasov totally understand that concern. If we can get this PR updated to use the .cancel() instead of .abort() I would be happy to release this. I'll drop the note on this PR as well. #370

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants