As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
Kinvey Support
So I have managed to replicate this error 100%
I have tried with latest SDK v3.3.3 and this code snippet will throw NoActiveUserError constantly
Scenario 1:
This code is called on document ready. It will throw NoActiveUserError every time. You can see I have put the retry trick in there. This code will fail all five times. Interestingly I forgot the iterator first time and it ended up in an infinite loop of NoActiveUserError haha.
Scenario 2:
I put a button on the page that calls the exact same code id=test that I click the moment it loads. The code executes without a problem
Code:
I have a custom end point that queries a couple collections and returns.
$(document).ready(function() { 'use strict'; // Setup var promise = Kinvey.initialize({ appKey: 'kid_rywxSOz7g', appSecret: 'dc66ca4a631a4f1eb61efe8c7752a2a2', sync: { enable: true, online: navigator.onLine } }).then(function(activeUser) { //Auto-generate the active user if not defined. //if(null === activeUser) { // return Kinvey.User.create(); //} }).then(null, function(error) { alert(error); }); getReportData('586cb916ed5cb51f47e9ee25'); $('#test').click(function(){ console.log('Test button clicked') getReportData('586cb916ed5cb51f47e9ee25'); }) }); // POPULATE REPORT - GET DATA - call custom end point to retrieve report data. var retry_count = 0 function getReportData(inspection_id) { console.log(Kinvey.User.getActiveUser()); var request_body = { inspection_id:inspection_id }; var promise = Kinvey.CustomEndpoint.execute('get-report', request_body); promise.then(function onSuccess(report_data) { console.log(report_data); var retry_count = 0 }).catch(function onError(error) { if(error.name === "NoActiveUserError" && retry_count < 5){ retry_count++ getReportData(inspection_id); } console.log(error); }); }
Here is a snip of the log.
You can see the first five fails and then the button is clicked and code executes as intended
fun fact... putting a 1000ms delay in my retry makes the retry work first time, every time..
$(document).ready(function() { 'use strict'; // Setup var promise = Kinvey.initialize({ appKey: 'kid_rywxSOz7g', appSecret: //appKey, sync: { enable: true, online: navigator.onLine } }).then(function(activeUser) { //Auto-generate the active user if not defined. //if(null === activeUser) { // return Kinvey.User.create(); //} }).then(null, function(error) { alert(error); }); getReportData('586cb916ed5cb51f47e9ee25'); $('#test').click(function(){ getReportData('586cb916ed5cb51f47e9ee25'); }) }); // POPULATE REPORT - GET DATA - call custom end point to retrieve report data. var retry_count = 0 function getReportData(inspection_id) { console.log(Kinvey.User.getActiveUser()); var request_body = { inspection_id:inspection_id }; var promise = Kinvey.CustomEndpoint.execute('get-report', request_body); promise.then(function onSuccess(report_data) { console.log(report_data); var retry_count = 0 }).catch(function onError(error) { if(error.name === "NoActiveUserError" && retry_count < 5){ retry_count++ setTimeout(function(){ getReportData(inspection_id); }, 1000); } console.log(error); }); }
Phil K
Hi guys. Dev with V3.3.2
I keep getting intermittent NoActiveUserErrors when I am doing queries on data and file collections. I have a user logged in and if the code immediately retries it will execute fine. It only seems to happen mostly when a page is loading but not always.
Not sure how I can give more useful info but here are some details
User is logged in
Javascript files linked after body
Kinvey linked before calling files
Kinvey initialized before other code
Calls are made inside $(document).ready()
Generally occurs when a page is loading but not always
Happens on file and data collections
I have implemented immediate retry which will work most times on the first try - .catch() calls the function again with iterator to count max retries
Sorry I can't seem to find any pre-conditions that are creating it.
NoActiveUserErrorcode:-1debug:""message:"There is not an active user. Please login a user and retry the request."name:"NoActiveUserError"stack:"Error: There is not an active user. Please login a user and retry the request.↵ at NoActiveUserError.KinveyError (https://da189i1jfloii.cloudfront.net/js/kinvey-html5-sdk-3.3.2.js:2457:20)↵ at new NoActiveUserError (https://da189i1jfloii.cloudfront.net/js/kinvey-html5-sdk-3.3.2.js:2983:120)↵ at Object.session (https://da189i1jfloii.cloudfront.net/js/kinvey-html5-sdk-3.3.2.js:21569:43)↵ at KinveyRequest.getAuthorizationHeader (https://da189i1jfloii.cloudfront.net/js/kinvey-html5-sdk-3.3.2.js:21660:29)↵ at KinveyRequest.execute (https://da189i1jfloii.cloudfront.net/js/kinvey-html5-sdk-3.3.2.js:21690:20)↵ at KinveyObservable._subscribe (https://da189i1jfloii.cloudfront.net/js/kinvey-html5-sdk-3.3.2.js:34373:25)↵ at KinveyObservable.Observable.subscribe (https://da189i1jfloii.cloudfront.net/js/kinvey-html5-sdk-3.3.2.js:5123:28)↵ at https://da189i1jfloii.cloudfront.net/js/kinvey-html5-sdk-3.3.2.js:5056:17↵ at initializePromise (https://da189i1jfloii.cloudfront.net/js/kinvey-html5-sdk-3.3.2.js:6275:6)↵ at new Promise (https://da189i1jfloii.cloudfront.net/js/kinvey-html5-sdk-3.3.2.js:6687:32)"__proto__:KinveyErrorconstructor:NoActiveUserError()length:0name:"NoActiveUserError"prototype:KinveyError__proto__:KinveyError(name)[[FunctionLocation]]:kinvey-html5-sdk-3.3.2.js:2976[[Scopes]]:Scopes[3]__proto__:ExtendableErrorconstructor:KinveyError(name)__proto__:Error
Cheers