joepie91 / node-bhttp

A sane HTTP client library for Node.js with Streams2 support.
62 stars 12 forks source link

Global leak: code #1

Closed garthk closed 9 years ago

garthk commented 9 years ago
$ node
> global.code
undefined
> var bhttp = require('bhttp')
undefined
> global.code
'511'
joepie91 commented 9 years ago

I suspect that's caused by the errors dependency. I'll have a look into it, and file a bug there if necessary.

joepie91 commented 9 years ago

The issue was indeed with the errors dependency, I've submitted a pull request there that fixes it.

If this is a breaking issue for you, a workaround along the lines of the following (untested) should work, until it's fixed upstream:

if (typeof global.code !== "undefined") { var oldCode = global.code; }
var bhttp = require("node-bhttp");
if (typeof oldCode !== "undefined") { global.code = oldCode; }
joepie91 commented 9 years ago

An update for errors has been pushed to npm, that should have solved this problem.