Skip to content

http: remove duplicate async_hooks init for http parser

Each time a new parser was created, AsyncReset was being called via the C++ Parser class constructor (super constructor AsyncWrap) and also via Parser::Reinitialize.

This also adds a missing async_hooks destroy event before AsyncReset is called for the parser reuse case, otherwise the old async_id never gets destroyed.

Refs: #19859 (closed)

See also: https://github.com/nodejs/node/pull/23201

Checklist

I was not yet able to write a decent test case for that, but the changes to test/async-hooks/test-graph.http.js already prove that the duplicated init hook call (which was actually tested for there) has been removed. I see what I can do about adding a more explicit test.

Update: There is a test now but it only works when I restrict it to the init hooks called in the http client context. Without this restriction, there are still init calls without a matching destroy so I suspect there is still in issue when using parsers in http server.

Update 2: I was able to remove the restriction on _http_client init calls, it was a test issue after all.

Merge request reports

Loading