NJS Questions and/or Bugs

Lance Dockins lance at wordkeeper.com
Thu Aug 12 03:47:54 UTC 2021


Also, just to be clear, you’re saying that r.args should include parsed POST vars?  Obviously it includes query string/GET vars.  That works.  But the values in the POST body do not show up in the args output.  And again, I basically see nothing coming up in the output for variables.

This:

# Pass PHP requests to PHP-FPM
location ~ \.php$ {
	limit_req zone=post_limit burst=5 nodelay;
	limit_req_status 429;

	set $test 0;

	add_header Content-Type text/plain;
	js_content dbadmin.access;
}

function access(r){

    var jObj = JSON.stringify(r.args) + '\n';
    jObj = JSON.stringify(r.variables);

    try {
        var parseJSON = JSON.parse(jObj);
    } catch (err) {
        r.return(400, 'Cannot parse jObj');
        return;
    }

    r.return(200, jObj);

    return;
}

export default {access}


Shows nothing.  Just an empty JSON object like {}


--
Lance Dockins
Minister of Magic
WordKeeper
Office: 405.585.2500
Cell: 405.306.7401
https://wordkeeper.com
On Aug 11, 2021, 10:44 PM -0500, Lance Dockins <lance at wordkeeper.com>, wrote:
> Something is definitely wrong here but I’ve stripped most of the more advanced configuration out of the vhost conf, removed all modules other than NJS, and set the Nginx compile to pretty much the most vanilla compile option set that I can to rule out the possibility of 3rd party interference with this.  Nothing is having any impact on the args var output.  For POST, it’s always an empty object.  For GET, it’s always showing the query string vars in a key/value pair (if there are any).  The variables and rawVariables objects always seem to be empty but I’m not setting any vars with NJS right now.  I’m only setting those in Nginx.
>
> At this point, if you’re saying that it should be working, I’m inclined to think that I’ve discovered some sort of bug.  Debug didn’t turn up anything unexpected.  I’m not the most well versed person at parsing through debug logs but it all looked like expected stuff to me.
>
> Moreover, the config that I was using at the start of this conversation is a config that is working on multiple thousands of production websites on well over 100 servers that we care for with no issues whatsoever.  Not to mention that that config works just fine with LuaJIT.  The only difference was that we swapped out the LuaJIT hooks for NJS to see how that might work instead.   But like I said, at this point, even with no 3rd party modules, no patches of any sort, very basic compile settings, and no fancy use of Nginx settings (e.g. extensive use of IF), it’s just not working.
>
> So either I have stumbled across some flaw in NJS or there’s a misunderstanding somewhere in the discussion.
>
>
> --
> Lance Dockins
>
> On Aug 11, 2021, 10:00 PM -0500, Lance Dockins <lance at wordkeeper.com>, wrote:
> > Unfortunately, we can’t really use standard packages.  We need extra modules.  I’m recompiling and enabling debug now.  The modules we’re using aren’t anything super abnormal and we might replace one of them with NJS at some point.  All I know for sure is that this seems to work just fine with OpenResty’s LuaJIT integration/module.  So it’s something that is different between NJS and that.
> >
> > Hopefully the debug will turn something up.
> >
> >
> > --
> > Lance Dockins
> >
> > On Aug 11, 2021, 9:57 PM -0500, Sergey A. Osokin <osa at freebsd.org.ru>, wrote:
> > > On Wed, Aug 11, 2021 at 09:48:48PM -0500, Lance Dockins wrote:
> > > > I’ll try recompiling nginx with that to see if that changes anything.
> > >
> > > I'd recommend to use official packages for Linux from the following URL,
> > > http://nginx.org/en/linux_packages.html
> > >
> > > > In fact, even your code is returning nothing.
> > >
> > > That's definitely something wrong on your side. Please simplify the
> > > nginx configuration, remove all unnecessary directives.
> > >
> > > ...
> > >
> > > > When I submit a POST with vars, I still get an empty object in the response.
> > >
> > > A couple of suggestions:
> > >
> > > - Have you enabled debugging log? If so, could you share nginx-error.log.
> > > - How did you test the code? Here's my shell script:
> > >
> > > #!/bin/sh
> > >
> > > curl -v --data-binary @test.bin http://127.0.0.1:8080/test?foo=bar\&baz=1
> > >
> > > #EOF
> > >
> > > Please report when all suggested points are done, thanks.
> > >
> > > --
> > > Sergey
> > > _______________________________________________
> > > nginx mailing list
> > > nginx at nginx.org
> > > http://mailman.nginx.org/mailman/listinfo/nginx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20210811/547ec18b/attachment-0001.htm>


More information about the nginx mailing list