Skip to content

Callback was already called error from async  #115

@lavayj

Description

@lavayj

const sp = new saml2.ServiceProvider(sso_options.sp_options);
const params = querystring.parse(event.body);

// Our field from the request.
const samlResponse = params['SAMLResponse'];

log.debug(samlResponse);
const req ={};
req.SAMLResponse = samlResponse;
const options = {request_body:req};
const idp = new saml2.IdentityProvider(sso_options.idp_options);
log.debug(options);
sp.post_assert(idp,options,function(err, assertionResponse){
if(err){
log.error(err);
throw(err);
} else {

log.debug(assertionResponse);
const userId = assertionResponse.user.name_id;
const firstName = assertionResponse.user.attributes.firstName[0];
const lastName = assertionResponse.user.attributes.lastName[0];
const email = assertionResponse.user.attributes.email[0];
const accessToken = auth.createAccessToken(userId,firstName,lastName,email,'User');

}})})

I get the below error after i receive the assertionResponse and see the log statement. It seems the callback is invoked before completion of the async calls. What could be the issue ?

2017-09-29T16:58:01.202Z 58dea4fa-a537-11e7-ac37-2b1c78b060d2 Error: Callback was already called.
at /var/task/node_modules/saml2-js/node_modules/async/dist/async.js:903:32
at /var/task/node_modules/saml2-js/lib-js/saml2.js:658:16
at nextTask (/var/task/node_modules/saml2-js/node_modules/async/dist/async.js:5297:14)
at next (/var/task/node_modules/saml2-js/node_modules/async/dist/async.js:5304:9)
at /var/task/node_modules/saml2-js/node_modules/async/dist/async.js:906:16
at /var/task/node_modules/saml2-js/lib-js/saml2.js:633:20
at nextTask (/var/task/node_modules/saml2-js/node_modules/async/dist/async.js:5297:14)
at next (/var/task/node_modules/saml2-js/node_modules/async/dist/async.js:5304:9)
at /var/task/node_modules/saml2-js/node_modules/async/dist/async.js:906:16
at /var/task/node_modules/saml2-js/lib-js/saml2.js:607:16

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions