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

Unhandled error when initializing client for unknown user #35

Closed
jrbarron opened this issue Apr 24, 2017 · 2 comments
Closed

Unhandled error when initializing client for unknown user #35

jrbarron opened this issue Apr 24, 2017 · 2 comments
Labels

Comments

@jrbarron
Copy link

This was discovered while running autotests for our app so is probably not critical to production.

If the Unleash client is initialized without specifying an instanceId then the client will attempt to generate one using os.userInfo and os.hostname. This can result in an unhandled error in some cases because os.userInfo will throw an error if the user running the process does not have an entry in the /etc/passwd file on *nix systems. Here is a stack trace from our app:

/usr/src/app/node_modules/unleash-client/lib/unleash.js:44
            var info = os_2.userInfo();
                            ^

Error: ENOENT: no such file or directory, uv_os_get_passwd
    at Error (native)
    at new Unleash (/usr/src/app/node_modules/unleash-client/lib/unleash.js:44:29)
    at initialize (/usr/src/app/node_modules/unleash-client/lib/index.js:8:16)

See GetUserInfo in Node's os module:

https://github.com/nodejs/node/blob/master/src/node_os.cc#L354

Since there is already a fallback for the case where info.username is empty, it probably makes sense to put a try/catch around the call to userInfo() and ensure the fallback gets used if an error is thrown.

In the meantime, the workaround is simply to pass in a instanceId when initializing Unleash.

@ivarconr ivarconr added the bug label Apr 24, 2017
@ivarconr
Copy link
Member

Ai, thanks. Fortunately it should be easy to provide a fix for this one!

ivarconr pushed a commit that referenced this issue Apr 27, 2017
ivarconr pushed a commit that referenced this issue Apr 27, 2017
ivarconr added a commit that referenced this issue Apr 27, 2017
Unleash initalize should not fail when os.userInfo() throws #35
@ivarconr
Copy link
Member

fixed in 2.1.2

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

No branches or pull requests

2 participants