summaryrefslogtreecommitdiffhomepage
path: root/src/nodejs (follow)
AgeCommit message (Collapse)AuthorFilesLines
2022-06-02Node.js: fixed ES modules format in loader.mjs.Andrei Zeliankou1-2/+2
Before Node.js v16.14.0 the "format" value in defaultResolve was ignored so error was hidden. For more information see: https://github.com/nodejs/node/pull/40980
2021-10-28Moving request limit control to libunit.Max Romanov2-3/+4
Introducting application graceful stop. For now only used when application process reach request limit value. This closes #585 issue on GitHub.
2021-06-15Node.js: improving and test packaging.Max Romanov1-22/+0
The patch removes the "files" section from package.json to avoid future issues with missing files. For package testing purposes, 'npm pack' is used instead of plain 'tar' to simulate packaging more accurately.
2021-06-02Node.js: packaging new loader.js and loader.mjs.Max Romanov1-0/+2
The files loader.js and loader.mjs (introduced in f85b85094541 and 3c551b9721df) were added to the packaged files list.
2021-05-24Node.js: renamed "require_shim" to "loader".Oisin Canty2-2/+2
2021-05-12Node.js: a shim for overriding "http" and "websocket" modules.Oisin Canty4-12/+72
Also added stubs for Server.address() This was done to prevent crashes in some popular frameworks like express Supports both CommonJS and the new ES Modules system syntax e.g: app.js: const http = require('http') app.mjs: import http from "http" Usage on Node 14.16.x and higher: { "type": "external", "processes": {"spare": 0}, "working_directory": '/project', "executable": "/usr/bin/env", "arguments": [ "node", "--loader", "unit-http/require_shim.mjs" "--require", "unit-http/require_shim", "app.js" ] } Usage on Node 14.15.x and lower: { "type": "external", "processes": {"spare": 0}, "working_directory": '/project', "executable": "/usr/bin/env", "arguments": [ "node", "--require", "unit-http/require_shim", "app.js" ] }
2021-03-25Node.js: used distinct placeholder for version in "package.json".Valentin Bartenev1-1/+1
This makes the "sed" instruction simpler and more portable, as the previous variant didn't work well on BSD systems due to the "\s" metacharacter. Thanks to Sergey A. Osokin <osa@FreeBSD.org.ru> for spotting this issue. Also, this should prevent accidentally creating a version 1.0.0 package.
2020-12-29Libunit: processing single port message.Max Romanov1-43/+133
This partially reverts the optimisation introduced in 1d84b9e4b459 to avoid an unpredictable block in nxt_unit_process_port_msg(). Under high load, this function may never return control to its caller, and the external event loop (in Node.js and Python asyncio) won't be able to process other scheduled events. To reproduce the issue, two request processing types are needed: 'fast' and 'furious'. The 'fast' one simply returns a small response, while the 'furious' schedules asynchronous calls to external resources. Thus, if Unit is subjected to a large amount of 'fast' requests, the 'furious' request processing freezes until the high load ends. The issue was found by Wu Jian Ping (@wujjpp) during Node.js stream implementation discussion and relates to PR #502 on GitHub.
2020-12-29Node.js: ServerRequest and ServerResponse compliance to Stream API.Max Romanov3-44/+87
ServerRequest now inherit stream Readable object. ServerResponse provides 'writable' property. Thanks to Wu Jian Ping (@wujjpp). This closes #274, closes #317 issues and closes #502 PR on GitHub.
2020-12-07Node.js: avoided use of request struct for debug logging.Max Romanov1-3/+3
This fixes a crash on exit of Node.js application. The crash reproduced on Ubuntu 20.10 with Node.js v15.1.0. Tests 'test_node_websockets_two_clients' and 'test_node_websockets_7_13_1__7_13_2'. The reason of the crash is using request struct which was already freed. The issue was introduced in 5be509fda29e.
2020-11-30Node.js: removing unnecessary warnings.Max Romanov1-18/+6
Warnings changed for debug messages.
2020-11-18Libunit: closing active requests on quit.Max Romanov1-0/+2
2020-08-11Introducing the shared application port.Max Romanov1-13/+9
This is the port shared between all application processes which use it to pass requests for processing. Using it significantly simplifies the request processing code in the router. The drawback is 2 more file descriptors per each configured application and more complex libunit message wait/read code.
2020-08-11Libunit refactoring: port management.Max Romanov2-25/+23
- Changed the port management callbacks to notifications, which e. g. avoids the need to call the libunit function - Added context and library instance reference counts for a safer resource release - Added the router main port initialization
2020-08-07Node.js: correct port data memory release.Max Romanov1-1/+15
According to libuv documentation, uv_poll_t memory should be released in a callback function passed to uv_close(). Otherwise, the Node.js application process may crash at exit.
2020-04-08Node.js: fixing Server.listen() method.Max Romanov1-1/+11
This is required for Express framework compatibility. This closes #418 issue on GitHub.
2020-03-03Node.js: fixing x86 warning about the signed/unsigned comparison.Max Romanov1-2/+1
2020-01-28Node.js: suppress compilation warning.Max Romanov1-1/+1
2019-12-24Node.js: implementing output message drain using SHM_ACK feature.Max Romanov3-26/+188
ServerResponse.write() method tries to write data buffer using libunit and stores buffers to write in a Server-wide output queue, which is processed in response to SHM_ACK message from router. As a side effect 'drain' event implemented and socket.writable flag reflect current state.
2019-11-11Fixing libunit 'off by 2' issue in library.Max Romanov1-9/+12
Name and value in each header are 0-terminated, so additional 2 bytes should be allocated for them. There were several attempts to add these 2 bytes to headers in language modules, but some modules weren't updated. Also, adding these 2 bytes is specific to the implementation which may be changed later, so extending this mechanics to modules may cause errors.
2019-08-20Node.js: introducing websocket support.Max Romanov15-175/+2373
2019-08-06Node.js: returning "this" from writeHead() to allow chaining.Valentin Bartenev1-0/+2
In Node.js version 11.10.0 and later, the writeHead() function returns "this".
2019-06-17Node.js: packaging new nxt_napi.h.Max Romanov1-0/+1
File nxt_napi.h (introduced in 53533ba0097c) added into packaged files list. This closes #261 issue on GitHub.
2019-04-17Node.js: using low-case header names as key in req.headers.Max Romanov1-4/+17
Node.js modules (body-parser, row-body) search low-cased names ('content-length', 'content-type' etc.) to properly assemble request body. This closes #246 issue on GitHub.
2019-04-03Backed out changeset f74d4dd9c3db.Valentin Bartenev1-0/+8
This closes #240 issue on GitHub.
2019-04-02Removing unused variables and assignments.Max Romanov1-8/+5
Warnings introduced in 53533ba0097c commit.
2019-04-01Adding 'connection' to request as an alias to 'socket'.Max Romanov1-4/+11
Adding actual 'remoteAddress' and 'localAddress' into socket object. This closes #232 issue on GitHub.
2019-04-01Introducing close event to notify about server stop.Max Romanov2-0/+25
This closes #236 on GitHub. Thanks to 0xcdcdcdcd.
2019-04-01Adding syntax sugar.Max Romanov5-654/+882
With exceptions and overloads.
2019-03-11Style.Andrey Zelenkov1-1/+1
2019-02-22Improvement and unification of version processing in build scripts.Alexander Borisov1-1/+1
This also eliminates expressions that incompatible with BSD make, thus fixing installation of Node.js module on FreeBSD (broken by dace60fc4926).
2018-12-19Node.js: removed value checking for headers.Alexander Borisov1-8/+0
2018-12-19Node.js: removed unused _implicitHeader() function.Alexander Borisov1-5/+0
2018-12-19Node.js: added check for libunit version at compile time.Alexander Borisov2-6/+12
2018-12-19libunit: added generation of version header file.Alexander Borisov1-1/+1
2018-12-19Node.js: checking for exception after running JS code from C++.Alexander Borisov1-3/+20
2018-12-19Node.js: checking uniqueness of HTTP headers for different case.Alexander Borisov2-24/+62
2018-12-19Node.js: calling write callback asynchronously.Alexander Borisov1-1/+13
2018-12-19Node.js: style fixes.Alexander Borisov1-8/+10
No functional changes.
2018-12-19Node.js: changed the unit-http socket constructor.Alexander Borisov1-5/+10
Third-party file descriptors are not supported. Socket "readable" and "writable" options are set true by default.
2018-12-19Node.js: napi_call_function() replaced with napi_make_callback().Alexander Borisov2-27/+63
The sequence of napi_open_callback_scope(), napi_call_function(), and napi_close_callback_scope() functions calls executes the provided JS code and all functions enqueued by process.nextTick() and Promises during this execution.
2018-12-19Node.js: changed the 'data' event calling sequence for the request.Alexander Borisov1-10/+30
The problem is caused by Promises' inconsistency. The 'date' event could have been triggered before the user has started listening for it. To resolve the issue, we override the 'on' method of the request's emitter.
2018-12-19Node.js: buffering HTTP headers before writing the body.Alexander Borisov1-10/+13
2018-12-12Node.js: removed unused dependency.Valentin Bartenev1-4/+1
2018-11-15Node.js: npm package readme cleanup.Valentin Bartenev1-18/+2
2018-11-15Node.js: res.write() must return a bool value.Alexander Borisov1-1/+1
2018-11-15Node.js: fixed handling of response header fields.Alexander Borisov2-1/+26
This fixes two issues: - values for mutiple header fields with the same name passed as arrays were converted to string; - the type of field value wasn't preserved as required by specification.
2018-11-15Node.js: added correct exit processing.Alexander Borisov2-18/+43
Node.js processes didn't exit after the changes in b9f7635e6be2, as the quit command from port wasn't handled by the module.
2018-11-15Node.js: added reference count increment for the Unit object.Alexander Borisov2-0/+13
We increase the number to the Unit object so that it lives forever. This is necessary so that the garbage collector does not delete the Unit object.
2018-11-06Node.js: socket.js improvements.Andrey Zelenkov1-18/+20
- Fixed handling of the "options" parameter in Socket() constructor; - Now the connect() method returns "this"; - Deduplicated the address() method; - Added missing "callback" argument to the end() method; - Now the destroy() method returns "this"; - Added "timeout" argument type check in the setTimeout() method.