parser.incoming = null;
req.parser = parser;
+ // Propagate headers limit from request object to parser
+ if (typeof req.maxHeadersCount === 'number') {
+ parser.maxHeaderPairs = req.maxHeadersCount << 1;
+ } else {
+ // Set default value because parser may be reused from FreeList
+ parser.maxHeaderPairs = 2000;
+ }
+
socket._httpMessage = req;
- // Setup "drain" propogation.
+ // Setup 'drain' propogation.
httpSocketSetup(socket);
- var errorListener = function(err) {
+ function errorListener(err) {
debug('HTTP SOCKET ERROR: ' + err.message + '\n' + err.stack);
- req.emit('error', err);
- // For Safety. Some additional errors might fire later on
- // and we need to make sure we don't double-fire the error event.
- req._hadError = true;
+ if (req) {
+ req.emit('error', err);
+ // For Safety. Some additional errors might fire later on
+ // and we need to make sure we don't double-fire the error event.
+ req._hadError = true;
+ }
if (parser) {
parser.finish();
freeParser(parser, req);
Local<Value> error = try_catch.Exception();
Local<Value> event_argv[2] = { uncaught_exception_symbol_l, error };
- uncaught_exception_counter++;
+ TryCatch event_try_catch;
emit->Call(process, 2, event_argv);
- // Decrement so we know if the next exception is a recursion or not
- uncaught_exception_counter--;
++
+ if (event_try_catch.HasCaught()) {
+ // the uncaught exception event threw, so we must exit.
+ ReportException(event_try_catch, true);
+ exit(1);
+ }
+
+ // This makes sure uncaught exceptions don't interfere with process.nextTick
+ StartTickSpinner();
}
// source code.)
// The node.js file returns a function 'f'
--
atexit(AtExit);
TryCatch try_catch;
};
};
+ startup.processConfig = function() {
+ // used for `process.config`, but not a real module
+ var config = NativeModule._source.config;
+ delete NativeModule._source.config;
+
+ // strip the gyp comment line at the beginning
+ config = config.split('\n').slice(1).join('\n').replace(/'/g, '"');
+
+ process.config = JSON.parse(config, function(key, value) {
+ if (value === 'true') return true;
+ if (value === 'false') return false;
+ return value;
+ });
+ }
+
startup.processNextTick = function() {
var nextTickQueue = [];
+ var nextTickIndex = 0;
process._tickCallback = function() {
- var l = nextTickQueue.length;
- if (l === 0) return;
-
- var q = nextTickQueue;
- nextTickQueue = [];
-
- try {
- for (var i = 0; i < l; i++) {
- var tock = q[i];
- var callback = tock.callback;
- if (tock.domain) {
- if (tock.domain._disposed) continue;
- tock.domain.enter();
- }
- callback();
- if (tock.domain) tock.domain.exit();
+ var nextTickLength = nextTickQueue.length;
+ if (nextTickLength === 0) return;
+
+ while (nextTickIndex < nextTickLength) {
- nextTickQueue[nextTickIndex++]();
++ var tock = nextTickQueue[nextTickIndex++];
++ var callback = tock.callback;
++ if (tock.domain) {
++ if (tock.domain._disposed) continue;
++ tock.domain.enter();
+ }
- }
- catch (e) {
- if (i + 1 < l) {
- nextTickQueue = q.slice(i + 1).concat(nextTickQueue);
- }
- if (nextTickQueue.length) {
- process._needTickCallback();
++ callback();
++ if (tock.domain) {
++ tock.domain.exit();
+ }
- throw e; // process.nextTick error, or 'error' event on first tick
}
+
+ nextTickQueue.splice(0, nextTickIndex);
+ nextTickIndex = 0;
};
process.nextTick = function(callback) {
before
- node.js:*
- throw e; // process.nextTick error, or 'error' event on first tick
- ^
+ *test*message*throw_custom_error.js:31
-throw { name: 'MyCustomError', message: 'This is a custom message' };
++throw ({ name: 'MyCustomError', message: 'This is a custom message' });
+ ^
MyCustomError: This is a custom message
before
- node.js:*
- throw e; // process.nextTick error, or 'error' event on first tick
- ^
+ */test/message/throw_non_error.js:31
-throw { foo: 'bar' };
++throw ({ foo: 'bar' });
+ ^
[object Object]