Skip to content

http: add missing async_hooks destroy before asyncReset

Emit a destroy before calling asyncReset because otherwise the old async_id never gets destroyed.

Refs: https://github.com/nodejs/node/issues/19859

This fixes one of the two issues described in here: https://github.com/nodejs/node/issues/19859#issuecomment-425815157, namely the missing destroy event when an http agent gets reused.

Reasoning: When calling asyncReset on the socket, we need to be aware that this will overwrite the socket's asyncId. The asyncId assigned to the socket before asyncReset is then lost, thus, a destroy event will never be emitted for this "old" asyncId. The added emitDestroy makes sure that a matching destroy event is emitted before we assign the new asyncId in asyncReset.

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

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Merge request reports

Loading