| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Review requested:
|
Sorry, something went wrong.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #65066 +/- ##
==========================================
- Coverage 90.30% 90.28% -0.03%
==========================================
Files 759 759
Lines 247644 247761 +117
Branches 46687 46716 +29
==========================================
+ Hits 223645 223693 +48
- Misses 15474 15520 +46
- Partials 8525 8548 +23
... and 38 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Sorry, something went wrong.
There was a problem hiding this comment.
Nice work, thanks for fixing this @shani-singh1!
Commit linting is failing as there's no sign-off trailer, so you'll need to git commit --amend -s and then force push to update it.
Sorry, something went wrong.
`maybeEnableKeylog()` runs as the agent's `'newListener'` handler and
attaches the agent's keylog handler to the sockets the agent already
owns. `agent.sockets` maps a name to an array of sockets, but the loop
treated those arrays as sockets and called `.on()` on them.
Adding a `'keylog'` listener to an agent that already owned a socket
therefore threw `TypeError: sockets[i].on is not a function` out of
`agent.on('keylog', ...)`. Since the throw happened inside the
`'newListener'` handler it propagated before the listener was stored,
so the caller got an exception and no listener. Sockets parked in
`agent.freeSockets` were never visited at all.
Walk both maps the way `Agent.prototype.destroy()` does.
Signed-off-by: Shani Singh <teamdeveloperworld@gmail.com>
|
Thanks for the review! Amended with -s and force pushed, so the head is now 9058cd0 and carries the sign-off trailer. I applied the same to my three other open PRs (#65064, #65065, #65067) since they would have hit the same lint failure once CI ran on them. |
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
`maybeEnableKeylog()` runs as the agent's `'newListener'` handler and
attaches the agent's keylog handler to the sockets the agent already
owns. `agent.sockets` maps a name to an array of sockets, but the loop
treated those arrays as sockets and called `.on()` on them.
Adding a `'keylog'` listener to an agent that already owned a socket
therefore threw `TypeError: sockets[i].on is not a function` out of
`agent.on('keylog', ...)`. Since the throw happened inside the
`'newListener'` handler it propagated before the listener was stored,
so the caller got an exception and no listener. Sockets parked in
`agent.freeSockets` were never visited at all.
Walk both maps the way `Agent.prototype.destroy()` does.
Signed-off-by: Shani Singh <teamdeveloperworld@gmail.com>
PR-URL: #65066
Reviewed-By: Tim Perry <pimterry@gmail.com>
`maybeEnableKeylog()` runs as the agent's `'newListener'` handler and
attaches the agent's keylog handler to the sockets the agent already
owns. `agent.sockets` maps a name to an array of sockets, but the loop
treated those arrays as sockets and called `.on()` on them.
Adding a `'keylog'` listener to an agent that already owned a socket
therefore threw `TypeError: sockets[i].on is not a function` out of
`agent.on('keylog', ...)`. Since the throw happened inside the
`'newListener'` handler it propagated before the listener was stored,
so the caller got an exception and no listener. Sockets parked in
`agent.freeSockets` were never visited at all.
Walk both maps the way `Agent.prototype.destroy()` does.
Signed-off-by: Shani Singh <teamdeveloperworld@gmail.com>
PR-URL: #65066
Reviewed-By: Tim Perry <pimterry@gmail.com>
| Back | FazBrowse Home | New Git URL |
maybeEnableKeylog() runs as the agent's 'newListener' handler and attaches the agent's keylog handler to the sockets the agent already owns:
agent.sockets maps a name to an array of sockets, so ObjectValues() yields arrays, not sockets, and .on() is called on an array. Agent.prototype.destroy() in the same file gets this right with a nested walk over both maps.
Two things follow. Adding a 'keylog' listener to an agent that already owns a socket throws, and because the throw happens inside the 'newListener' handler it propagates out of agent.on() before the listener is stored, so the caller gets an exception and no listener. Separately, agent.freeSockets is never visited, so idle keep-alive sockets never start listening even once the crash is out of the way.
Reproduction
On v24.11.1:
bucket is an Array : true agent.on("keylog") : THREW TypeError: sockets[i].on is not a function keylog listeners : 0 (expected 1)The documented 'keylog' event on https.Agent is therefore unusable on any agent that has already opened a socket, which is the normal case for a long-lived agent. The existing coverage in test/parallel/test-https-agent-keylog.js registers the listener on https.globalAgent before any request is made, so agent.sockets is empty and the loop body never runs.
Change
Walk both maps the same way Agent.prototype.destroy() does.
Verification
Running the old and new loop bodies against a real http.Agent holding one idle socket and one in-flight socket:
The added test uses two servers so the sockets get different names and one stays parked in freeSockets rather than being reused. It fails on main with the TypeError above at the agent.on('keylog', ...) line, and passes with this change.