core: updated inlined code from async-listener with latest code
core: updated inlined code from async-listener with latest code

This commit is a cherry-pick of 3681f0b74056037f762544fa3cc62834400e76f5

opbeat/opbeat-node,opbeat/opbeat-node