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

node-uuid 1.3.2 not working with node v0.4.12 #30

Closed
gavinuhma opened this issue Jan 2, 2012 · 4 comments
Closed

node-uuid 1.3.2 not working with node v0.4.12 #30

gavinuhma opened this issue Jan 2, 2012 · 4 comments

Comments

@gavinuhma
Copy link

crypto.randomBytes wasn't added until node v0.6.0. The compatibility check (try/catch) doesn't work.

_rb gets set as undefined and doesn't fail until it's later called (outside of the try/catch).

https://github.com/broofa/node-uuid/blob/master/uuid.js#L44

resulting error:

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
TypeError: undefined is not a function
    at CALL_NON_FUNCTION (native)
    at /app/node_modules/node-uuid/uuid.js:47:14
    at /app/node_modules/node-uuid/uuid.js:103:20
    at Object.<anonymous> (/app/node_modules/node-uuid/uuid.js:249:1)
    at Module._compile (module.js:411:26)
    at Object..js (module.js:417:10)
    at Module.load (module.js:343:31)
    at Function._load (module.js:302:12)
    at require (module.js:355:19)
@gavinuhma
Copy link
Author

something like this should work (not tested)..

try {
  var _rb = require('crypto').randomBytes;
  if (_rb) {
    nodeRNG = function() {
      return _rb(16);
    };
  }
} catch (e) {}

@broofa broofa closed this as completed in 8a6c03f Jan 2, 2012
@broofa
Copy link
Member

broofa commented Jan 2, 2012

Thx for the report, @gavinuhma. Sorry for any inconvenience. (fwiw, I was testing on v0.5.8, where randomBytes() is defined, so I guess this was added somewhere in 0.5.x.)

@broofa
Copy link
Member

broofa commented Jan 2, 2012

Oh, and 1.3.3 is npm-published, so an npm update should fix things.

@gavinuhma
Copy link
Author

great. thanks :)

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