Git Product home page Git Product logo

njs's People

Contributors

abonavita avatar almazyr avatar andrey-zelenkov avatar arut avatar besteltrap avatar devnexen avatar disconnect3d avatar drsm avatar hongzhidao avatar hyeonisism avatar i4ki avatar igorsysoev avatar jirutka avatar jo-carter avatar kapouer avatar mdocguard avatar mtbchef avatar orgads avatar osokin avatar piotrsikora avatar pluknet avatar shankerwangmiao avatar thresheek avatar vadimzhestikov avatar vbart avatar xeioex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

njs's Issues

the Function() method stub returns invalid value

while the Function() constructor is a stub, it should throw InternalError, i think.
and there is problem around it and maybe in other places aswell

>> new Function
undefined
    at native (native)
    at main (native)

>> throw new Error('test')
Error: test
    at main (native)

>> new Function
Error: test
    at native (native)
    at main (native)

does this patch resolve the problem or just hide it?

# HG changeset patch
# User Artem S. Povalyukhin <[email protected]>
# Date 1532731490 -10800
#      Sat Jul 28 01:44:50 2018 +0300
# Node ID a8811f27d1d0c976734ab20743d9121ed10be3dc
# Parent  058162fce59aa3136de927db6246a6a4d5b7e025
Fixed return value of Function() method stub.

diff -r 058162fce59a -r a8811f27d1d0 njs/njs_function.c
--- a/njs/njs_function.c        Fri Jul 27 17:01:52 2018 +0300
+++ b/njs/njs_function.c        Sat Jul 28 01:44:50 2018 +0300
@@ -457,6 +457,8 @@
 njs_function_constructor(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
     njs_index_t unused)
 {
+    njs_internal_error(vm, "Not implemented");
+
     return NXT_ERROR;
 }

Methods of external objects are not native Function objects

From #19

>> console.log.bind
TypeError: cannot get property 'bind' of undefined
    at main (native)
>> console.log
undefined

However...

>> console.log(1)
1

The console is an external object for the njs VM. It is created by njs command line tool. Currently, external objects are treated in a different way in comparison to native VM objects.

ngx_postgres module does not support subrequests in memory

Пытаюсь дёрнуть постгрес из njs:

function dbtst(r) {
  r.subrequest('/dbtst/302834/', '', function(res) {
    r.warn('DEBUG: res.status=' + res.status + ';');
  });
}

Получаю в логе:

2018/06/29 12:44:55 [error] 30069#30069: *149 postgres: ngx_postgres module does not support subrequests in memory, client: 127.0.0.1, server: localhost, request: "GET /jstst/ HTTP/1.1", subrequest: "/dbtst/302834/", host: "localhost:8009"
2018/06/29 12:44:55 [warn] 30069#30069: *149 js: DEBUG: res.status=500;

В коде ngx_postgres есть такие буковки:

if (r->subrequest_in_memory) {
        /* TODO: add support for subrequest in memory by
         * emitting output into u->buffer instead */

        ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
                      "postgres: ngx_postgres module does not support"
                      " subrequests in memory");

        dd("returning NGX_HTTP_INTERNAL_SERVER_ERROR");
        return NGX_HTTP_INTERNAL_SERVER_ERROR;
}

В то же время, из lua модуля подобный подзапрос работает. Но lua как раз пытаюсь заменить njs'ом. Как правильнее решить проблему? Понятно, что идеально было бы допилить ngx_postgres, но просить агента ж бесполезно, а сам я врядли смогу сделать приемлемый патч.

Возможно ли добавить опцию в r.subrequest, чтобы можно было делать не in-memory подзапросы?

Messages are buffered until a different type of message arrives

I am running an njs function to replace a few bytes in MQTT publish packages. the function runs well, but the packages are not transmitted until another type of package arrives. When a MQTT subscribe, unsubscribe, connect etc. message is received all the buffered messages are transmitted at once.

function updateTopic(s) {
  if (!s.fromUpstream) {
    if(s.buffer.indexOf("topic") != -1){
      s.buffer = s.buffer.replace("topic", "mopic").toBytes();
    }
  }
  return s.OK;
}

Object.getOwnPropertyDescriptor and array length property

the length property in an empty array is handled incorrectly, and for non empty array an invalid result is returned:

>> JSON.stringify(Object.getOwnPropertyDescriptor([], 'length'))
"undefined"
>> JSON.stringify(Object.getOwnPropertyDescriptor([1,2,3], 'length'))
{"value":1,"configurable":"true","enumerable":"true","writable":"true"}

Object.getOwnPropertyDescriptor handles missing arguments incorrectly

>> Object.getOwnPropertyDescriptor([])
TypeError: cannot convert array argument to object
    at Object.getOwnPropertyDescriptor (native)
    at main (native)

>> Object.getOwnPropertyDescriptor({})
TypeError: cannot convert object argument to object
    at Object.getOwnPropertyDescriptor (native)
    at main (native)
>> Object.getOwnPropertyDescriptor({}, undefined)
undefined

No support for arguments object?

function f() {
  console.log(arguments);
}
f(1, 2, 3);

Produces:

ReferenceError: "arguments" is not defined in 1

I expect the following output:

[1,2,3]

"the http output chain is empty while connecting to upstream" from subrequest

I run minimal latest nginx version with latest dynamic ngx_http_js_module.so, and the module works fine to execute some NJS example, except in related with subrequest.

$ nginx -V
nginx version: nginx/1.15.2
built by gcc 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)
built with OpenSSL 1.1.0f  25 May 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --sbin-path=/usr/local/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --user=www-data --group=www-data --with-http_stub_status_module --without-http_ssi_module --without-http_userid_module --without-http_access_module --without-http_auth_basic_module --without-http_autoindex_module --without-http_geo_module --without-http_map_module --without-http_split_clients_module --without-http_fastcgi_module --without-http_uwsgi_module --without-http_scgi_module --without-http_memcached_module --without-http_limit_conn_module --without-http_limit_req_module --without-http_empty_gif_module --without-http_browser_module --without-http_upstream_ip_hash_module --without-http_upstream_least_conn_module --without-http_upstream_keepalive_module --with-http_ssl_module --with-http_v2_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/body --with-pcre --with-debug --add-dynamic-module=../njs-0.2.3/nginx

I use an NJS example:

// fastresponse.js
function content(r) {
    var n = 0;

    function done(res) {
        if (n++ == 0) {
            r.return(res.status, res.responseBody);
        }
    }

    r.subrequest('/foo', r.variables.args, done);
    r.subrequest('/bar', r.variables.args, done);
}

and the conf:

# nginx.conf
...
js_include fastresponse.js;

location / {
    js_content content;
}

location /foo {
    proxy_pass http://somedomain1.tld;
}

location /bar {
    proxy_pass http://somedomain2.tld;
}
...

curl result:

λ curl -v http://somedomain.tld
* STATE: INIT => CONNECT handle 0x6000595e0; line 1103 (connection #-5000)
* Rebuilt URL to: http://somedomain.tld/
* Added connection 0. The cache now contains 1 members
*   Trying 11.22.33.44...
* STATE: CONNECT => WAITCONNECT handle 0x6000595e0; line 1156 (connection #0)
* Connected to somedomain.tld (11.22.33.44) port 80 (#0)
* STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x6000595e0; line 1253 (connection #0)
* STATE: SENDPROTOCONNECT => DO handle 0x6000595e0; line 1271 (connection #0)
> GET / HTTP/1.1
> Host: somedomain.tld
> User-Agent: curl/7.47.1
> Accept: */*
>
* STATE: DO => DO_DONE handle 0x6000595e0; line 1350 (connection #0)
* STATE: DO_DONE => WAITPERFORM handle 0x6000595e0; line 1477 (connection #0)
* STATE: WAITPERFORM => PERFORM handle 0x6000595e0; line 1487 (connection #0)
* STATE: PERFORM => DONE handle 0x6000595e0; line 1645 (connection #0)
* Curl_done
* Empty reply from server
* Connection #0 to host somedomain.tld left intact
* Expire cleared
curl: (52) Empty reply from server

But still able to retrieve 200 responses from /foo and /bar

λ curl -v -X HEAD http://somedomain.tld/foo
...
> HEAD /foo HTTP/1.1
> Host: somedomain.tld
> User-Agent: curl/7.47.1
> Accept: */*
>
* STATE: DO => DO_DONE handle 0x6000595e0; line 1350 (connection #0)
* STATE: DO_DONE => WAITPERFORM handle 0x6000595e0; line 1477 (connection #0)
* STATE: WAITPERFORM => PERFORM handle 0x6000595e0; line 1487 (connection #0)
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 200 OK
* Server nginx/1.15.2 is not blacklisted
< Server: nginx/1.15.2
< Date: Fri, 03 Aug 2018 03:19:09 GMT
< Content-Type: text/html; charset=utf-8
< Connection: keep-alive
...

error.log

2018/08/03 03:15:59 [alert] 29420#0: *20 the http output chain is empty while connecting to upstream, client: 7.8.9.10, server: somedomain.tld, request: "GET / HTTP/1.1", host: "somedomain.tld"
2018/08/03 03:15:59 [error] 29420#0: *20 pending events while closing request, client: 7.8.9.10, server: 0.0.0.0:80

Does the errors produces in related with --without-http_upstream-* modules?

Thanks for any replies.

Object.getOwnPropertyDescriptor() should not query an object's prototype chain

>> var p = Object.create(null);
undefined
>> p.one = 1;
1
>> 'one' in p
true
>> var o = Object.create(p);
undefined
>> 'one' in o
true
>> JSON.stringify(Object.getOwnPropertyDescriptor(p, 'one'));
{"value":1,"configurable":true,"enumerable":true,"writable":true}
>> JSON.stringify(Object.getOwnPropertyDescriptor(o, 'one'));
{"value":1,"configurable":true,"enumerable":true,"writable":true}

subRequest to a named location

Hi

I'd like my njs function to manipulate the req body and then send it along to a private location that is not exposed in the conf file as a public location. I tried

req.subrequest('@myNamedLocation', ...

and

req.subrequest('http://my.private.url', ...

but in both cases nginx looked in the html folder for a file with these names.

Please advise on how I can best achieve this use case.

Thanks,
Matt

js_content + auth_request + proxy_pass = timeout

$ cat recaptcha.js 

function recaptcha(req, res) {
  res.return(204);
}
$ cat recaptcha.conf 
js_include conf.d/recaptcha.js;

server {
    listen 2121;
    server_name localhost;

    error_log  /var/log/nginx/recaptcha.error.log debug;
    access_log  /var/log/nginx/recaptcha.access.log main;

    location = /recaptcha {
        js_content recaptcha;
        #return 204;    
    }
}

server {
    listen 2323;
    server_name localhost;

    error_log  /var/log/nginx/recaptcha.error.log debug;
    access_log  /var/log/nginx/recaptcha.access.log main;

    location = /recaptcha {
        proxy_method GET;
        proxy_pass http://localhost:2121;
    }

    location = /test {
        auth_request /recaptcha;
        proxy_pass http://localhost:2424;
    }
}

server {
    listen 2424;
    server_name localhost;

    error_log  /var/log/nginx/recaptcha.error.log debug;
    access_log  /var/log/nginx/recaptcha.access.log main;

    location = /test {
        return 200 '{ "ok": true }';    
    }
}
$ curl -v -X POST http://localhost:2323/test --data-raw '{"login":"login", "password":"password"}' && echo
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 2323 (#0)
> POST /test HTTP/1.1
> Host: localhost:2323
> User-Agent: curl/7.47.0
> Accept: */*
> Content-Length: 40
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 40 out of 40 bytes
< HTTP/1.1 500 Internal Server Error
< Server: nginx/1.13.12
< Date: Mon, 07 May 2018 17:37:26 GMT
< Content-Type: text/html
< Content-Length: 194
< Connection: close
< 
<html>
<head><title>500 Internal Server Error</title></head>
<body bgcolor="white">
<center><h1>500 Internal Server Error</h1></center>
<hr><center>nginx/1.13.12</center>
</body>
</html>
* Closing connection 0

$ tail -n 2 /var/log/nginx/recaptcha.error.log 
2018/05/07 20:37:26 [error] 4155#4155: *8 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "POST /test HTTP/1.1", subrequest: "/recaptcha", upstream: "http://127.0.0.1:2121/recaptcha", host: "localhost:2323"
2018/05/07 20:37:26 [error] 4155#4155: *8 auth request unexpected status: 504 while sending to client, client: 127.0.0.1, server: localhost, request: "POST /test HTTP/1.1", host: "localhost:2323"

build njs 0.2.0 with nginx 1.12.2 error: 'NGX_HTTP_SUBREQUEST_BACKGROUND' undeclared

nginx version: 1.12.2
njs version: 0.2.0

./auto/configure --add-dynamic-module=/nginxmodules/njs/nginx

error:

	/nginxmodules/njs/nginx/ngx_http_js_module.c
/nginxmodules/njs/nginx/ngx_http_js_module.c: In function 'ngx_http_js_subrequest':
/nginxmodules/njs/nginx/ngx_http_js_module.c:1806:13: error: 'NGX_HTTP_SUBREQUEST_BACKGROUND' undeclared (first use in this function)
     flags = NGX_HTTP_SUBREQUEST_BACKGROUND;
             ^
/nginxmodules/njs/nginx/ngx_http_js_module.c:1806:13: note: each undeclared identifier is reported only once for each function it appears in
objs/Makefile:2680: recipe for target 'objs/addon/nginx/ngx_http_js_module.o' failed
make[1]: Leaving directory '/nginxmodules/nginx'
make[1]: *** [objs/addon/nginx/ngx_http_js_module.o] Error 1
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 2

fallback to default toString() implementation

in console.* & interactive shell

>> var x = Object.create(null);
undefined
>> x
TypeError: cannot evaluate an object's value
    at main (native)

>> console.log(x)
TypeError: cannot evaluate an object's value
    at console.log (native)
    at main (native)
    at main (native)

>> console.log(Object.prototype.toString(x))
[object Object]
undefined
>> Object.prototype.toString(x)
[object Object]

is it possible to extend require() to load external files?

with some restrictions to prevent misuse:

// works only at global scope
var one = require('path/to/one');
var path = 'path/to/two';
var two = require(path);

function handler(r) {
    var one = require('path/to/one'); // ok, it is in the cache
    var three = require('path/to/three'); // throws
}

external objects are not really JS objects

$ ./njs
interactive njscript 0.2.1

v.<Tab> -> the properties and prototype methods of v.
type console.help() for more information

>> typeof console
undefined
>> typeof console.log
undefined

Currently objects created externally (request from nginx module, for example) are implemented in a completely different way from native JS objects (NJS_EXTERNAL value type). It means that in every JS function a special branch is needed to support externals.

Instead external objects should be implemented using generic primitives used for native JS objects.
As a result external objects will be indistinguishable from native objects and will be supported by all JS functions.

interactive shell: autocompletion list corruption

the autocompletion list is corrupted after the value of any property of any global object was accessed.

$ njs
interactive njs 0.2.2

v.<Tab> -> the properties and prototype methods of v.
type console.help() for more information

>> n
native      new         njs         njs.version null       
>> njs.version
0.2.2
>> njs
njs         njs         njs.version
>> njs.
njs.__proto__      njs.constructor    njs.hasOwnProperty njs.isPrototypeOf  njs.toString       njs.valueOf        njs.version        njs.version       
>> Math.
Math.__proto__ Math.asin      Math.atanh     Math.cos       Math.expm1     Math.imul      Math.log10     Math.LOG2E     Math.pow       Math.sin       Math.SQRT2    
Math.abs       Math.asinh     Math.cbrt      Math.cosh      Math.floor     Math.LN10      Math.LOG10E    Math.max       Math.random    Math.sinh      Math.tan      
Math.acos      Math.atan      Math.ceil      Math.E         Math.fround    Math.LN2       Math.log1p     Math.min       Math.round     Math.sqrt      Math.tanh     
Math.acosh     Math.atan2     Math.clz32     Math.exp       Math.hypot     Math.log       Math.log2      Math.PI        Math.sign      Math.SQRT1_2   Math.trunc    
>> Math.PI
3.14159
>> Math.
Math.__proto__      Math.atan           Math.constructor    Math.floor          Math.LN2            Math.LOG2E          Math.round          Math.SQRT2         
Math.__proto__      Math.atan           Math.cos            Math.fround         Math.log            Math.max            Math.sign           Math.tan           
Math.abs            Math.atan2          Math.cos            Math.fround         Math.log            Math.max            Math.sign           Math.tan           
Math.abs            Math.atan2          Math.cosh           Math.hasOwnProperty Math.log10          Math.min            Math.sin            Math.tanh          
Math.acos           Math.atanh          Math.cosh           Math.hypot          Math.log10          Math.min            Math.sin            Math.tanh          
Math.acos           Math.atanh          Math.E              Math.hypot          Math.LOG10E         Math.PI             Math.sinh           Math.toString      
Math.acosh          Math.cbrt           Math.E              Math.imul           Math.LOG10E         Math.PI             Math.sinh           Math.trunc         
Math.acosh          Math.cbrt           Math.exp            Math.imul           Math.log1p          Math.pow            Math.sqrt           Math.trunc         
Math.asin           Math.ceil           Math.exp            Math.isPrototypeOf  Math.log1p          Math.pow            Math.sqrt           Math.valueOf       
Math.asin           Math.ceil           Math.expm1          Math.LN10           Math.log2           Math.random         Math.SQRT1_2       
Math.asinh          Math.clz32          Math.expm1          Math.LN10           Math.log2           Math.random         Math.SQRT1_2       
Math.asinh          Math.clz32          Math.floor          Math.LN2            Math.LOG2E          Math.round          Math.SQRT2         
>> Math.

req.subrequest() there is no way to specify/override HTTP headers

    location = /check {
        internal;
        proxy_set_header Accept-Encoding '';
        proxy_set_header Content-Type 'application/x-www-form-urlencoded';
        proxy_pass https://www.google.com/recaptcha/api/siteverify;
    }

while proxying i can solve this, but if a subrequest hits a js_content location there is no way.

Object.defineProperty() should respect configuration when the property is redefined

>> var y = {}
undefined
>> Object.defineProperty(y, 'y', { configurable: true });
{
 
}
>> Object.defineProperty(y, 'y', { configurable: true });
[object Object]
    at Object.defineProperty (native)
    at main (native)

>> var z = {}
undefined
>> Object.defineProperty(z, 'z', {});
{
 
}
>> Object.defineProperty(z, 'z', {});
[object Object]
    at Object.defineProperty (native)
    at main (native)

various issues with empty array items and array length property

tested with njs -V 0.2.0

>> var test = [1,2,3];
undefined
>> Object.keys(test);
0,1,2
>> test.length = 4;
4
>> Object.keys(test);
0,1,2,length
>> test[4] = 'some';
some
>> Object.keys(test);
0,1,2,4,length
>> test.length
4
>> JSON.stringify(test)
MemoryError
    at JSON.stringify (native)
    at main (native)
>> var test = [1,2,3];
undefined
>> test[4] = 'some';
some
>> test.length
5

for (k in o) loop is broken

>> var x = Object.create(null);
undefined
>> x.one = 1;
1
>> for (var a in x) console.log(a);
one
undefined
>> var y = Object.create(x);
undefined
>> for (var a in y) console.log(a);
undefined
>> 'one' in x
true
>> 'one' in y
true
>>

Missing headers in Request.headersOut

While trying to use njs to log request/response headers I noticed that some headers added by nginx are missing in the Request.headersOut

nginx version 1.14.0
njs version 0.2.2

I format headers as a stringified json object:

function escapeMap(map) {
  var result = {};
  for (var key in map) {
    result[key] = map[key];
  }

  return JSON.stringify(result);
}

...

responseHeaders: escapeMap(req.headersOut)`

Following headers present in the response are missing in the created object:

Server: nginx
Date: Thu, 02 Aug 2018 13:08:30 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 399
Connection: keep-alive

Possibility to run a shell command

Hi. It would be really useful if we were able to execute a shell command and return the output. I don't think it's possible right now, not at my knowledge at least.
Thank you.

njs and dynamic http2 server push

I am trying using njs to add Link header to enable dynamic http2 server push

// This code is based on the official example in http://nginx.org/en/docs/http/ngx_http_js_module.html
if (r.headersIn.cookie) {
    s += "Cookies:\n";
    var cookies = parse(r.headersIn.cookie); // https://github.com/jshttp/cookie/blob/master/index.js#L49
    for (var c in cookies) {
        s += "  cookie '" + c + "' is '" + cookies[c] + "'\n";
        r.headersOut.link = '</api/' + cookies[c] + '/test>; rel=preload; as=fetch; crossorigin';
    }
}

Which results in

$ nghttp -vs 'https://test.eoitek.net/summary' -H'cookie: a=1'                                 日  6/24 12:07:18 2018
[ERROR] Could not connect to the address ::1
Trying next address 127.0.0.1
[  0.009] Connected
The negotiated protocol: h2
[  0.011] recv SETTINGS frame <length=18, flags=0x00, stream_id=0>
          (niv=3)
          [SETTINGS_MAX_CONCURRENT_STREAMS(0x03):128]
          [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65536]
          [SETTINGS_MAX_FRAME_SIZE(0x05):16777215]
[  0.012] recv WINDOW_UPDATE frame <length=4, flags=0x00, stream_id=0>
          (window_size_increment=2147418112)
[  0.012] send SETTINGS frame <length=12, flags=0x00, stream_id=0>
          (niv=2)
          [SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
          [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[  0.012] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
          ; ACK
          (niv=0)
[  0.012] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
          (dep_stream_id=0, weight=201, exclusive=0)
[  0.012] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
          (dep_stream_id=0, weight=101, exclusive=0)
[  0.012] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
          (dep_stream_id=0, weight=1, exclusive=0)
[  0.012] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
          (dep_stream_id=7, weight=1, exclusive=0)
[  0.012] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
          (dep_stream_id=3, weight=1, exclusive=0)
[  0.012] send HEADERS frame <length=50, flags=0x25, stream_id=13>
          ; END_STREAM | END_HEADERS | PRIORITY
          (padlen=0, dep_stream_id=11, weight=16, exclusive=0)
          ; Open new stream
          :method: GET
          :path: /summary
          :scheme: https
          :authority: test.eoitek.net
          accept: */*
          accept-encoding: gzip, deflate
          user-agent: nghttp2/1.32.0
          cookie: a=1
[  0.012] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
          ; ACK
          (niv=0)
[  0.012] recv (stream_id=13) :status: 200
[  0.012] recv (stream_id=13) server: nginx/1.15.0
[  0.012] recv (stream_id=13) date: Sun, 24 Jun 2018 04:08:06 GMT
[  0.012] recv (stream_id=13) content-type: text/plain
[  0.012] recv (stream_id=13) content-length: 327
[  0.012] recv (stream_id=13) link: </api/1/test>; rel=preload; as=fetch; crossorigin
[  0.012] recv HEADERS frame <length=124, flags=0x04, stream_id=13>
          ; END_HEADERS
          (padlen=0)
          ; First response header
JS summary

Method: GET
HTTP version: 1.1
Host: test.eoitek.net
Remote Address: 127.0.0.1
URI: /summary
Headers:
  header 'host' is 'test.eoitek.net'
  header 'accept' is '*/*'
  header 'accept-encoding' is 'gzip, deflate'
  header 'user-agent' is 'nghttp2/1.32.0'
  header 'cookie' is 'a=1'
Cookies:
  cookie 'a' is '1'
Args:
[  0.012] recv DATA frame <length=327, flags=0x01, stream_id=13>
          ; END_STREAM
[  0.012] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
          (last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[])
***** Statistics *****

Request timing:
  responseEnd: the  time  when  last  byte of  response  was  received
               relative to connectEnd
 requestStart: the time  just before  first byte  of request  was sent
               relative  to connectEnd.   If  '*' is  shown, this  was
               pushed by server.
      process: responseEnd - requestStart
         code: HTTP status code
         size: number  of  bytes  received as  response  body  without
               inflation.
          URI: request URI

see http://www.w3.org/TR/resource-timing/#processing-model

sorted by 'complete'

id  responseEnd requestStart  process code size request path
 13      +855us       +238us    616us  200  327 /summary

The response header Link is added but no PUSH_PROMISE is given. I've set http2_push_preload on; and have tested add_header "Link ...", which works fine.

interactive shell - error state corruption

$ njs
interactive njs 0.2.3

v.<Tab> -> the properties and prototype methods of v.
type console.help() for more information

>> function () {}()
SyntaxError: Unexpected token "(" in 1
>> arguments
ReferenceError: "arguments" is not defined in 1
>> function () {}()
ReferenceError: "arguments" is not defined in 1
>> 

post args

how to get post args? res.args return only get

String object property lookup is broken

>> var x = new String('asdf');
undefined
>> x.one = 1;
1
>> 'one' in x
true
>> 0 in x
false
>> '0' in x
false
>> x[0]
undefined
>> x
asdf
>> x.valueOf()[0]
a
>> Object.getOwnPropertyDescriptor(x, 0)
undefined
>> JSON.stringify(Object.getOwnPropertyDescriptor(x, 'one'))
{"value":1,"configurable":true,"enumerable":true,"writable":true}

Cannot compile on gcc 4.4

Self-explanatory.

/opt/bin/musl-gcc -c -o build/nxt_strtod.o -D_GNU_SOURCE -pipe -fPIC -fvisibility=hidden -O -W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-prototypes -Werror -g -march=native -O3 -pipe -g -O2 -ffunction-sections -fdata-sections --param=ssp-buffer-size=4 -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \
		-Inxt \
		nxt/nxt_strtod.c
cc1: warnings being treated as errors
nxt/nxt_strtod.c: In function ‘nxt_adjust_pow10’:
nxt/nxt_strtod.c:115: error: control reaches end of non-void function
make[2]: *** [build/nxt_strtod.o] Error 1

strange error, tokenizer?

>> 2.toString()
SyntaxError: Unexpected token "toString" in 1
>> (function weird() { return 2.toString(); })()
2

typeof ([].length = '')

njs_value_number_set(retval, array->length);

diff -r e210675daceb njs/njs_array.c
--- a/njs/njs_array.c   Sun Jul 01 10:01:53 2018 +0300
+++ b/njs/njs_array.c   Sun Jul 01 13:11:29 2018 +0300
@@ -407,6 +407,9 @@
         }
 
         array->length = length;
+        retval = setval;
+
+        return NJS_OK;
     }
 
     njs_value_number_set(retval, array->length);

var kills

>> var x = 1;
undefined
>> var x = x * x;
undefined
>> x
NaN
>> (function() { var x = 1; var x = x * x; return x; })()
1
>>

internals: refactor error handling

>> var a = Array(1111111111)
1111111111
    at native (native)
    at main (native)

While looking into #41 I've found a ...
here njs_memory_error will be called twice:

njs/njs/njs_string.c

Lines 177 to 179 in bd2e5d8

njs_memory_error(vm);
return NXT_ERROR;

here it wont be called at all:

njs/njs/njs_string.c

Lines 149 to 151 in bd2e5d8

if (nxt_slow_path(string == NULL)) {
return NXT_ERROR;
}

but the return value of njs_string_create is used directly in many top level functions.

here:

return NXT_ERROR;

and so on...

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.