Coder Social home page Coder Social logo

hpicgs / node Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nodejs/node

0.0 0.0 0.0 336.53 MB

Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:

Home Page: https://nodejs.org

License: Other

Makefile 0.39% Shell 0.19% JavaScript 57.77% R 0.06% HTML 1.50% C++ 20.94% Python 13.38% DTrace 0.35% C 3.95% Roff 0.14% Batchfile 0.28% PHP 0.81% Emacs Lisp 0.13% Perl 0.11%

node's People

Contributors

addaleax avatar apapirovski avatar bnoordhuis avatar bridgear avatar cjihrig avatar danbev avatar evanlucas avatar felixge avatar fishrock123 avatar indutny avatar isaacs avatar jasnell avatar joyeecheung avatar koichik avatar mscdex avatar mylesborins avatar ofrobots avatar piscisaureus avatar rvagg avatar ry avatar sam-github avatar shigeki avatar targos avatar thefourtheye avatar timothygu avatar tjfontaine avatar tootallnate avatar trevnorris avatar trott avatar vsemozhetbyt avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node's Issues

Check which other PRs are changing Node`s start code

We should check which other developers are currently working on the Node startup code and inform them about our proposed changes.

I found this RFC / PR by accident:
nodejs#17058

"Yeah, the key issue is that node.js startup is a Tangled mess of spaghetti code right now. From the way cli args and env vars are processed, to the order of start up events, etc. I've been looking at introducing a proper command line args parser and start up options isolation that will be tied to the Environment rather than using global state, then will be separating out the initialization of the process object. Once that is done, we should be able to refactor the bootstrap script into distinct phases."

"Status update on this side: I've started working on refactoring the native bootstrap lifecycle.... starting with how configuration and command line options are handled.... specifically, moving away from use of global variables to using a NodeOptions class associated with the Environment. From there, I will be working through a refactoring of how the process object is bootstrapped."

Verify TickEventLoop code is correct

Carefully review what each function does in our TickEventLoop implementation and if we correctly set the more variable:

node/src/node.cc

Lines 4802 to 4818 in 2fae0db

inline static bool TickEventLoop(Environment & env) {
bool more;
uv_run(env.event_loop(), UV_RUN_ONCE);
v8_platform.DrainVMTasks();
more = uv_loop_alive(env.event_loop());
if (more)
return more;
EmitBeforeExit(&env);
// Emit `beforeExit` if the loop became alive either after emitting
// event, or after running some callbacks.
more = uv_loop_alive(env.event_loop());
return more;
}

Investigate process.exit() and node.js termination

When process.exit() is called, an exit event seems to be dispatched. To figure out how to properly handle this in our terminate method, we need to understand how this works. Is it added to the event queue? Is the event queue cleared before? Is the event dispatched outside of the event loop?

According to your findings, modify node::lib::Terminate().

Offer more convenience methods

  • Easier creation of v8 object (e.g. v8::MaybeLocal<v8::String> node::lib::CreateString(const std::string & input))
  • Try-Catch wrapper (e.g. v8::Exception node::lib::TryCatch(const std::function & function))

(Im not entirely sure about the exact definition of the TryCatch wrapper. However, I think this would still be a great addition)

User Story: Call C++ from JS

As a C++ enthusiast, I want to call C++ methods from the JS code / .js file. It'd be mind-blowingly amazing if I didn't have to register these methods beforehand. If I do have to, I want to have a simple registerCppFunc(string name, function_pointer f) function in nodeLib. It would be extra cool if I could also pass a callback as function_pointer.

User Story: Main Loop Callback

As a Qt enthusiast, I want to pass a callback/function_pointer to nodeLib, which is regularly called from inside the Node.js main loop, so that my Qt application doesn't freeze while Node.js runs.

Build tests in Travis

In addition, we should all be running the tests before approving and/or opening PRs. You can run all tests with make test.

Fix 15 currently broken tests

Result of make test-only on the current node_lib branch returns 15 failed JS tests (see below). On the master branch of this fork, these tests run successfully.

The C++ tests all passed.

=== release test-cli-syntax ===                                                
Path: parallel/test-cli-syntax
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 'Embedded mode\n' === ''
    at /home/m/Desktop/node/test/parallel/test-cli-syntax.js:101:10
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (/home/m/Desktop/node/test/parallel/test-cli-syntax.js:96:12)
    at Module._compile (module.js:641:30)
    at Object.Module._extensions..js (module.js:652:10)
    at Module.load (module.js:560:32)
    at tryModuleLoad (module.js:503:12)
    at Function.Module._load (module.js:495:3)
    at Function.Module.runMain (module.js:682:10)
    at startup (bootstrap_node.js:191:16)
Command: out/Release/node /home/m/Desktop/node/test/parallel/test-cli-syntax.js


=== release test-cwd-enoent-repl ===                                           
Path: parallel/test-cwd-enoent-repl
Embedded mode
events.js:193
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at _errnoException (util.js:1031:13)
    at Pipe.onread (net.js:619:25)
Command: out/Release/node /home/m/Desktop/node/test/parallel/test-cwd-enoent-repl.js


=== release test-force-repl ===                                                
Path: parallel/test-force-repl
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 'Embedded mode\n' === '> '
    at Socket.<anonymous> (/home/m/Desktop/node/test/parallel/test-force-repl.js:13:10)
    at Socket.<anonymous> (/home/m/Desktop/node/test/common/index.js:522:15)
    at Object.onceWrapper (events.js:324:30)
    at emitOne (events.js:125:13)
    at Socket.emit (events.js:221:7)
    at addChunk (_stream_readable.js:265:12)
    at readableAddChunk (_stream_readable.js:248:13)
    at Socket.Readable.push (_stream_readable.js:209:10)
    at Pipe.onread (net.js:598:20)
Command: out/Release/node /home/m/Desktop/node/test/parallel/test-force-repl.js


=== release test-force-repl-with-eval ===                   
Path: parallel/test-force-repl-with-eval
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: false == true
    at process.<anonymous> (/home/m/Desktop/node/test/parallel/test-force-repl-with-eval.js:22:3)
    at emitOne (events.js:130:20)
    at process.emit (events.js:221:7)
Command: out/Release/node /home/m/Desktop/node/test/parallel/test-force-repl-with-eval.js


=== release test-preload ===                                                   
Path: parallel/test-preload
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 'A\nEmbedded mode\n' === 'A\n> '
    at ChildProcess.<anonymous> (/home/m/Desktop/node/test/parallel/test-preload.js:98:10)
    at emitTwo (events.js:135:13)
    at ChildProcess.emit (events.js:224:7)
    at maybeClose (internal/child_process.js:943:16)
    at Socket.stream.socket.on (internal/child_process.js:363:11)
    at emitOne (events.js:125:13)
    at Socket.emit (events.js:221:7)
    at Pipe._handle.close [as _onclose] (net.js:558:12)
Command: out/Release/node /home/m/Desktop/node/test/parallel/test-preload.js


=== release test-repl-harmony ===                                              
Path: parallel/test-repl-harmony
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: false == true
    at Socket.<anonymous> (/home/m/Desktop/node/test/parallel/test-repl-harmony.js:44:3)
    at emitNone (events.js:120:20)
    at Socket.emit (events.js:218:7)
    at endReadableNT (_stream_readable.js:1054:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
Command: out/Release/node /home/m/Desktop/node/test/parallel/test-repl-harmony.js


=== release test-repl-require-context ===                         
Path: parallel/test-repl-require-context
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: [ 'Embedded mode', '' ] deepStrictEqual [ 'undefined', 'true', 'true', '' ]
    at ChildProcess.child.on.common.mustCall (/home/m/Desktop/node/test/parallel/test-repl-require-context.js:18:10)
    at ChildProcess.<anonymous> (/home/m/Desktop/node/test/common/index.js:522:15)
    at emitTwo (events.js:135:13)
    at ChildProcess.emit (events.js:224:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
Command: out/Release/node /home/m/Desktop/node/test/parallel/test-repl-require-context.js


=== release test-repl-sigint ===                                 
Path: parallel/test-repl-sigint
events.js:193
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at _errnoException (util.js:1031:13)
    at Pipe.onread (net.js:619:25)
Command: out/Release/node /home/m/Desktop/node/test/parallel/test-repl-sigint.js


=== release test-repl-sigint-nested-eval ===                        
Path: parallel/test-repl-sigint-nested-eval
events.js:193
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at _errnoException (util.js:1031:13)
    at Pipe.onread (net.js:619:25)
Command: out/Release/node /home/m/Desktop/node/test/parallel/test-repl-sigint-nested-eval.js


=== release test-repl-unexpected-token-recoverable ===                     
Path: parallel/test-repl-unexpected-token-recoverable
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: false == true
    at Socket.<anonymous> (/home/m/Desktop/node/test/parallel/test-repl-unexpected-token-recoverable.js:29:3)
    at emitNone (events.js:120:20)
    at Socket.emit (events.js:218:7)
    at endReadableNT (_stream_readable.js:1054:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
Command: out/Release/node /home/m/Desktop/node/test/parallel/test-repl-unexpected-token-recoverable.js


=== release test-stdin-script-child ===                                        
Path: parallel/test-stdin-script-child
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 'Embedded mode\n' === '22740\n'
    at ChildProcess.<anonymous> (/home/m/Desktop/node/test/parallel/test-stdin-script-child.js:27:12)
    at ChildProcess.<anonymous> (/home/m/Desktop/node/test/common/index.js:522:15)
    at emitTwo (events.js:135:13)
    at ChildProcess.emit (events.js:224:7)
    at maybeClose (internal/child_process.js:943:16)
    at Socket.stream.socket.on (internal/child_process.js:363:11)
    at emitOne (events.js:125:13)
    at Socket.emit (events.js:221:7)
    at Pipe._handle.close [as _onclose] (net.js:558:12)
Command: out/Release/node /home/m/Desktop/node/test/parallel/test-stdin-script-child.js


=== release test-stdin-script-child-option ===                    
Path: parallel/test-stdin-script-child-option
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 'Embedded mode' === '--option-to-be-seen-on-child'
    at Socket.child.stdout.on.common.mustCall (/home/m/Desktop/node/test/parallel/test-stdin-script-child-option.js:16:10)
    at Socket.<anonymous> (/home/m/Desktop/node/test/common/index.js:522:15)
    at emitNone (events.js:120:20)
    at Socket.emit (events.js:218:7)
    at endReadableNT (_stream_readable.js:1054:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
Command: out/Release/node /home/m/Desktop/node/test/parallel/test-stdin-script-child-option.js


=== release test-fs-readfile-tostring-fail ===                                 
Path: sequential/test-fs-readfile-tostring-fail
/home/m/Desktop/node/test/sequential/test-fs-readfile-tostring-fail.js:60
  throw err;
  ^

AssertionError [ERR_ASSERTION]: false == true
    at /home/m/Desktop/node/test/sequential/test-fs-readfile-tostring-fail.js:34:12
    at /home/m/Desktop/node/test/common/index.js:522:15
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:528:3)
Command: out/Release/node /home/m/Desktop/node/test/sequential/test-fs-readfile-tostring-fail.js


=== release test-repl-timeout-throw ===                                        
Path: sequential/test-repl-timeout-throw
Embedded mode
var throws = 0;process.on("exit",function(){console.log(throws)});function thrower(){console.log("THROW",throws++);XXX};setTimeout(thrower);""
events.js:193
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at _errnoException (util.js:1031:13)
    at Pipe.onread (net.js:619:25)
Command: out/Release/node /home/m/Desktop/node/test/sequential/test-repl-timeout-throw.js

User Story: Call JS from C++

As a Node.js enthusiast, I want to call JS methods from the passed .js file/JS code, whenever nodeLib returns control to my application (see Story #7 ).

bootstrap_node.js: Make reading from stdin configurable

Currently, Node.js is hacked to never read from stdin:

if (true) {
// TODO (cf): This should only happen if we run node via node::lib::Initialize().
// It should not run if we call node::lib::Start().
// Do nothing. Calling evalScript is necessary however, because it sets
// globals.require to the require function.
// Otherwise, require doesn't work.
console.log('Embedded mode');
evalScript('[eval]');
// If -i or --interactive were passed, or stdin is a TTY.
} else if (process._forceRepl || NativeModule.require('tty').isatty(0)) {

Add a command line parameter (?) to toggle this behaviour.

Fix failing linter

Based on the current node_lib branch, this is the output of make lint:

src/node.cc:4802:  Is this a non-const reference? If so, make const or use a pointer: Environment & env  [runtime/references] [2]
src/node.cc:4820:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5058:  At least two spaces is best between code and comments  [whitespace/comments] [2]
src/node.cc:5067:  Almost always, snprintf is better than strcpy  [runtime/printf] [4]
src/node.cc:5096:  At least two spaces is best between code and comments  [whitespace/comments] [2]
src/node.cc:5096:  Missing username in TODO; it should look like "// TODO(my_username): Stuff."  [readability/todo] [2]
src/node.cc:5097:  Should have a space between // and comment  [whitespace/comments] [4]
src/node.cc:5119:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5119:  At least two spaces is best between code and comments  [whitespace/comments] [2]
src/node.cc:5119:  Missing username in TODO; it should look like "// TODO(my_username): Stuff."  [readability/todo] [2]
src/node.cc:5120:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5125:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5125:  Should have a space between // and comment  [whitespace/comments] [4]
src/node.cc:5162:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5163:  At least two spaces is best between code and comments  [whitespace/comments] [2]
src/node.cc:5163:  Missing username in TODO; it should look like "// TODO(my_username): Stuff."  [readability/todo] [2]
src/node.cc:5164:  Should have a space between // and comment  [whitespace/comments] [4]
src/node.cc:5193:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5206:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5265:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5265:  Should have a space between // and comment  [whitespace/comments] [4]
src/node.cc:5266:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5269:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5269:  At least two spaces is best between code and comments  [whitespace/comments] [2]
src/node.cc:5269:  Missing username in TODO; it should look like "// TODO(my_username): Stuff."  [readability/todo] [2]
src/node.cc:5269:  Should have a space between // and comment  [whitespace/comments] [4]
src/node.cc:5275:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5275:  At least two spaces is best between code and comments  [whitespace/comments] [2]
src/node.cc:5275:  Missing username in TODO; it should look like "// TODO(my_username): Stuff."  [readability/todo] [2]
src/node.cc:5275:  Should have a space between // and comment  [whitespace/comments] [4]
src/node.cc:5283:  At least two spaces is best between code and comments  [whitespace/comments] [2]
src/node.cc:5283:  Missing username in TODO; it should look like "// TODO(my_username): Stuff."  [readability/todo] [2]
src/node.cc:5285:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5285:  Should have a space between // and comment  [whitespace/comments] [4]
src/node.cc:5302:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5303:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5306:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5310:  Missing username in TODO; it should look like "// TODO(my_username): Stuff."  [readability/todo] [2]
src/node.cc:5311:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5312:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5316:  Should have a space between // and comment  [whitespace/comments] [4]
src/node.cc:5317:  Missing username in TODO; it should look like "// TODO(my_username): Stuff."  [readability/todo] [2]
src/node.cc:5323:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5327:  Missing username in TODO; it should look like "// TODO(my_username): Stuff."  [readability/todo] [2]
src/node.cc:5329:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5333:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5333:  Missing username in TODO; it should look like "// TODO(my_username): Stuff."  [readability/todo] [2]
src/node.cc:5333:  Should have a space between // and comment  [whitespace/comments] [4]
src/node.cc:5334:  Missing username in TODO; it should look like "// TODO(my_username): Stuff."  [readability/todo] [2]
src/node.cc:5340:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5354:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5355:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5356:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5363:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5368:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node.cc:5380:  Should have a space between // and comment  [whitespace/comments] [4]
src/node.cc:5387:  Namespace should be terminated with "// namespace lib"  [readability/namespace] [5]
src/node_lib.h:0:  No #ifndef header guard found, suggested CPP variable is: SRC_NODE_LIB_H_  [build/header_guard] [5]
src/node_lib.h:12:  Do not indent within a namespace  [runtime/indentation_namespace] [4]
src/node_lib.h:12:  At least two spaces is best between code and comments  [whitespace/comments] [2]
src/node_lib.h:12:  Do not use unnamed namespaces in header files.  See https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Namespaces for more information.  [build/namespaces] [4]
src/node_lib.h:36:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node_lib.h:84:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node_lib.h:94:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node_lib.h:100:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node_lib.h:110:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node_lib.h:115:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node_lib.h:121:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node_lib.h:127:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node_lib.h:133:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node_lib.h:139:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/node_lib.h:140:  Namespace should be terminated with "// namespace lib"  [readability/namespace] [5]
src/node_lib.h:140:  Namespace should be terminated with "// namespace node"  [readability/namespace] [5]
Total errors found: 73

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.