Hidden threads in Javascript / Node that never execute user code: is it possible, and if so, could this lead to a secret possibility for the race condition?

See the bottom of the question for an update based on comments / answers. This question really concerns the possibility of hidden threads that do not make callbacks.


I have a question about a potential covert scenario involving a Node Query Module , in which:

  • A full HTTP request is created and executed over the network (taking at least several ms or even seconds)

  • ... before performing one function at runtime on the local computer (usually in nanoseconds?) - see below for more details

I place this mainly as a health check to make sure that I am not mistaken regarding the Node / JS / Request module code.

From the examples in the query module (see the SECOND example in this section):

// Copied-and-pasted from the second example in the 
// Node Request library documentation, here:
// https://www.npmjs.com/package/request#examples

// ... My ARCANE SCENARIO is injected in the middle

var request = require('request')
  request(
    { method: 'GET'
    , uri: 'http://www.google.com'
    , gzip: true
    }
  , function (error, response, body) {
      // body is the decompressed response body 
      console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity'))
      console.log('the decoded data is: ' + body)
    }
  )

    // **************************************************** //
    // Is the following scenario possible?
    //
    // <-- HANG HANG HANG HANG HANG HANG HANG HANG HANG -->
    //
    // Let us pretend that the current thread HANGS here,
    // but that the request had time to be sent,
    // and the response is pending being received by the thread
    //
    // <-- HANG HANG HANG HANG HANG HANG HANG HANG HANG -->
    // **************************************************** //

.on('data', function(data) {
    // decompressed data as it is received 
    console.log('decoded chunk: ' + data)
  })
  .on('response', function(response) {
    // unmodified http.IncomingMessage object 
    response.on('data', function(data) {
      // compressed data as it is received 
      console.log('received ' + data.length + ' bytes of compressed data')
    })
  })

I have indicated my secret script in the code snippet.

Suppose the Node process hangs at the specified point, but Node internally (in a hidden stream invisible to Javascript and therefore does not cause any callbacks) WAS able to build a request and send it over the network; suppose that the hang continues until a response is received (in two pieces, say) and awaits Node processing. (This is a scenario that is certainly a secret, and I'm not sure if this is even theoretically possible.)

, , Node . , , (- ) Node ( "" - - , ).

? , , , , 'data' ? , , , 'data' .

, , - , .

- , ?

, - . .


. . . " " , HIDDEN ( - USER, CALLBACKS), , - , 'data' callback - , 'response', () JS .

+2
3

, .

, "" , , . javascript , , . data , script/.

, , , , - makeRequest . , , script (- ) , , - . data, , .

+3

nodejs Javsacript . , . Javascript , , , , - (, , , ..).

nodejs ( - ), , . , - , , JS thread, .

nodejs , - . , JS , , - , .

, . nodejs Javascript, , , JS . callback , ( ), .

- , , , , nodejs, , - . nodejs , . - nodejs.

, :

: . " " , HIDDEN ( USER, CALLBACKS), , - - , - , "" , , () JS .

nodejs , JS- (, get put ). , JS- , ( , ..). , JS , , , - . . , , , - , JS , . , , , , . nodejs (, , -), , , . .

" -", nodejs.

+2

, Node.js; , , - . , .

0

All Articles