Modules: initialize the JS context of a completed subrequest
When a subrequest completed, its JS context was allocated by the
subrequest completion handler without ngx_js_ctx_init(), so the log and
the waiting events tree were not initialized. If the subrequest had no
JS context of its own, a reply received by the parent could then use
it:
- readRequest*() on the reply inserted a caller event into the
uninitialized tree;
- reading a js_set variable through reply.variables created an engine
for the uninitialized context.
Both crashed with both engines. The waiting events tree is missing
since
9de30135 (0.8.3), the log since
9b674412 (0.8.6).
Now the context is initialized as in ngx_http_js_init_vm(). Also,
deferred body reads are allowed only for the executing request, because
the body read state of a reply belongs to the subrequest.
Changed behaviour:
- readRequestText() and the other readRequest*() methods called on a
subrequest reply throw TypeError. They used to resolve with the body
of the parent request, or to crash when the body had to be read.