G
G
gleendo2017-07-25 20:38:51
Node.js
gleendo, 2017-07-25 20:38:51

Why does Cannot read property 'Symbol(asyncId)' of null occur?

node.js version is 8.2.1. I don't think it was the best choice.
Why does an error occur Cannot read property 'Symbol(asyncId)' of null?

Stack trace
_http_outgoing.js:636
    nextTick(msg.socket[async_id_symbol],
                       ^

TypeError: Cannot read property 'Symbol(asyncId)' of null
    at write_ (_http_outgoing.js:636:24)
    at ServerResponse.write (_http_outgoing.js:630:10)
    at Timeout.setTimeout [as _onTimeout] (C:\Users\iamevg_\Desktop\app\app.js:8:9)
    at ontimeout (timers.js:488:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:283:5)


The code:
let server = require("http").createServer().listen(8080);

server.on("request", (req, res) => {
  res.writeHead(200);
  res.write("Start");

  setTimeout(() => {
    res.write("Finish");
  }, 3000);

  req.on("data", msg => {
    console.log(msg.toString());
  });

  req.on("end", () => {
    res.end();
  });
});

Sending a request via curl curl -d "Hello" http://localhost:8080. The data comes in, but after the setTimeout expires, an error occurs. I just started learning node.js, so I can't even guess what the problem is. For a teacher, this code works fine, probably because it uses an earlier version.
PS. The first time the data buffer came in fine. First, "Start" was displayed, after 3 seconds "Finish". After that, the script finished running. Now comes the above case.
P.S.S. _ Tried again to send exactly the same request. Didn't change anything. Now an error pops up that recording occurs after the end.
stack trace
events.js:182
throw er; // Unhandled 'error' event
^
Error: write after end
at write_ (_http_outgoing.js:635:15)
at ServerResponse.write (_http_outgoing.js:630:10)
at Timeout.setTimeout [as _onTimeout] (C:\Users\iamevg_\Desktop\app\app.js:8:9)
at ontimeout (timers.js:469:11)
at tryOnTimeout (timers.js:304:5)
at Timer.listOnTimeout (timers.js:264:5)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Larisa Moroz, 2017-07-25
@larisamoroz

There's a bug: https://github.com/nodejs/node/issues/14368

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question