Skip to content

errno constants aren't properly defined in node 6 #95

Closed
@jnj16180340

Description

@jnj16180340

node-tmp uses the internal 'constants' module to define error codes, such as EBADF and ENOENT which should be caught during cleanup. In node 6, error codes have been removed from the 'constants' module.

So, in node 6:

> process.binding('constants').EBADF
undefined
> process.binding('constants').ENOENT
undefined
> process.binding('constants').os.errno.EBADF
9
> process.binding('constants').os.errno.ENOENT
2

in node 4:

> process.binding('constants').EBADF                                                                                                                                                                                                                                                            
9                                                                                                                                                                                                                                                                                       
> process.binding('constants').ENOENT                                                                                                                                                                                                                                                           
2   
> process.binding('constants').os
undefined
> process.binding('constants').os
undefined

It seems that _c.ENOENT should be replaced by _c.os.errno.ENOENT etc. in node 6.

And _c = require('constants') should be replaced by _c = process.binding('constants')... not really sure why the two aren't equal.

Alternately, constants can be generated from require('os').constants.errno and require('fs').constants in node 6.

Although using process.binding isn't recommended (see nodejs/node#2768 etc.), I'm using it for compatibility between node 4 and 6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions