Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit e5637c7

Browse files
authored
fix race condition with log points (#181)
Cannot assume that listeners[num] would still be valid across an async hop. It is possible that someone has cleared the log point across the timeout.
1 parent e38dc5c commit e5637c7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/v8debugapi.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,10 @@ module.exports.create = function(logger_, config_, jsFiles_, sourcemapper_) {
207207
if (logsThisSecond >= config.log.maxLogsPerSecond) {
208208
listeners[num].enabled = false;
209209
setTimeout(function() {
210-
if (!shouldStop()) {
210+
// listeners[num] may have been deleted by `clear` during the
211+
// async hop. Make sure it is valid before setting a property on
212+
// it.
213+
if (!shouldStop() && listeners[num]) {
211214
listeners[num].enabled = true;
212215
}
213216
}, config.log.logDelaySeconds * 1000);

0 commit comments

Comments
 (0)