hpicgs / node Goto Github PK
View Code? Open in Web Editor NEWThis project forked from nodejs/node
Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:
Home Page: https://nodejs.org
License: Other
This project forked from nodejs/node
Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:
Home Page: https://nodejs.org
License: Other
Node.js supports a lot of CLI flags, many of which could also be useful when running it as a shared library. We should allow setting these (e.g. by passing a string as a parameter) in the Initialize() call.
reference: https://nodejs.org/api/cli.html
As a Node.js enthusiast, I want to pass a string/stream containing JS code directly to nodeLib, asynchronously execute it and get its exit code sometime in the 'future'.
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."
Using node_isolate is preferred
Carefully review what each function does in our TickEventLoop
implementation and if we correctly set the more
variable:
Lines 4802 to 4818 in 2fae0db
@cmfcmf You said that eval
has to be called regardless whether -e
was given as a cmd argument or not, because it sets globals.require
to the require
module. Could you check if this is still true?
node/lib/internal/bootstrap_node.js
Lines 224 to 227 in 1959f89
As a Node.js enthusiast, I want to pass a path to a .js file directly to nodeLib, synchronously execute it and get its exit code.
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().
v8::MaybeLocal<v8::String> node::lib::CreateString(const std::string & input)
)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)
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.
Here:
Line 5207 in fd520a7
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.
The OpenSSL library should be deinitialized properly. See discussion here: #67
The deinit code could be added here:
Line 4946 in c77d2a1
see OpenSSL Wiki: https://wiki.openssl.org/index.php/Library_Initialization#Cleanup
e.g. Isolate
As a Node.js enthusiast, I want to pass a string/stream containing JS code directly to nodeLib, synchronously execute it and get its exit code.
In addition, we should all be running the tests before approving and/or opening PRs. You can run all tests with make test
.
Line 4802 in e2022c8
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
As a crazy maths professor, I want to be able to sum up to infinity by passing a variable n back and forth between a JS function and C++ function, each of them taking a number as parameter, incrementing it by 1 and returning it.
Currently we removed the returncode (return 12;
) from the function, however we should handle this error wherever it is called.
We'd like to find a better way than process.binding['CppModuleName'] to access our custom C++ module via JavaScript code.
Lines 5143 to 5145 in 6ac07ae
this enables us to bind native C++ modules in node without having to load a script. Was previously called at the beginning of (for example) our rss_feed JS part.
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 ).
Currently, Node.js is hacked to never read from stdin:
node/lib/internal/bootstrap_node.js
Lines 200 to 210 in 734d0d6
Add a command line parameter (?) to toggle this behaviour.
The callback is not always required, i.e. in the normal node Start() method.
Lines 158 to 160 in 1959f89
As a Node.js enthusiast, I want to pass a path to a .js file directly to nodeLib, asynchronously execute it and get its exit code sometime in the 'future'.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.