-
Notifications
You must be signed in to change notification settings - Fork 103
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
Fix issues with node 0.12 #73
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
language: node_js | ||
|
||
node_js: | ||
- 0.10 | ||
- "0.10" | ||
- "0.12" | ||
- iojs | ||
|
||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,10 +80,6 @@ exports.request = function (method, url, options, callback, _trace) { | |
var finish = function (err, res) { | ||
|
||
if (!callback || err) { | ||
if (res) { | ||
res.destroy(); | ||
} | ||
|
||
req.abort(); | ||
} | ||
|
||
|
@@ -177,6 +173,27 @@ exports.request = function (method, url, options, callback, _trace) { | |
req.write(options.payload); | ||
} | ||
|
||
// Custom abort method to detect early aborts | ||
|
||
var _abort = req.abort; | ||
var aborted = false; | ||
req.abort = function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not a fan of changing the node There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately not, as far as I can tell. This can only be resolved in node itself. You are welcome to submit a bug report. As it stands, if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Who else can call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But what is the use case? It's one thing to protect the wreck internals but I don't think wreck users should be calling abort. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is more of a question for node. It is part of the public api, and I guess they have a reason for it to be there. See http://nodejs.org/api/http.html#http_request_abort. It is inherently also part of the wreck api, with test cases to support it. Also, there is no way to remove this. My primary concern is that without this (or similar) patch, users can experience obscure timing related bugs when using abort. It is quite bad form to have a callback that is not always called. I definitely agree that it sucks to do this, and I ultimately think that this should be solved in node. Until then I think we have 3 options:
Finally, there is a small possibility that I'm wrong about the missing notification and it can be solved without a hack. You are welcome to look for it. |
||
|
||
if (!aborted && !req.res && !req.socket) { | ||
process.nextTick(function () { | ||
|
||
// Fake an ECONNRESET error | ||
|
||
var error = new Error('socket hang up'); | ||
error.code = 'ECONNRESET'; | ||
finish(error); | ||
}); | ||
} | ||
|
||
aborted = true; | ||
return _abort.call(req); | ||
}; | ||
|
||
// Finalize request | ||
|
||
req.end(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might as well add iojs