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

parseString() missing error management #4

Closed
AndreaFranchini opened this issue Mar 27, 2019 · 1 comment
Closed

parseString() missing error management #4

AndreaFranchini opened this issue Mar 27, 2019 · 1 comment

Comments

@AndreaFranchini
Copy link

Hi,
I was trying to open a PR but i have trouble with permissions.

In some cases xml2js.Parser parseString() can throw an error after execute the callback.

This leads to the emission of a node 'uncaughtException' in the express application.

Following lines (index.js 32-40)

parser.parseString(req.body, function(err, xml) {
    if(err) {
        err.status = 400;
        return next(err);
    }

    req.body = xml || req.body;
    next();
});

Should be wrapped

try {
    parser.parseString(req.body, function(err, xml) {
        if(err) {
            err.status = 400;
            return next(err);
        }
    
        req.body = xml || req.body;
        next();
    });
} catch (err) {
    // in some cases xml2js.Parser parseString() can
    // throw an error after execute the callback
    // see it source code for more details
}
@fiznool
Copy link
Owner

fiznool commented Mar 25, 2020

Fixed in v2.0.0

@fiznool fiznool closed this as completed Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants