<commit_before>/* eslint-disable comma-dangle */
'use strict';

const eventsByThread = {};
const inModules = [];

module.exports = {
  stalkFunction: stalkFunction,
  stalkEverything: stalkEverything,
};

function stalkFunction (config, address) {
  return new Promise((resolve, reject) => {
    const recursiveCountByThread = {};
    const threads = new Set();
    const completedThreads = new Set();

    _clearEvents();
    _initModules(config);

    const hook = Interceptor.attach(address, {
      onEnter () {
        tickAlive();

        this.myThreadId = Process.getCurrentThreadId();
        let recursiveCount = recursiveCountByThread[this.myThreadId] || 0;
        recursiveCount++;
        recursiveCountByThread[this.myThreadId] = recursiveCount;

        if (recursiveCount === 1) {
          threads.add(this.myThreadId);
          _followHere(config);
        }
      },

      onLeave () {
        tickAlive();

        let recursiveCount = recursiveCountByThread[this.myThreadId];
        recursiveCount--;
        recursiveCountByThread[this.myThreadId] = recursiveCount;

        if (recursiveCount === 0) {
          threads.delete(this.myThreadId);
          completedThreads.add(this.myThreadId);
          _unfollowHere();
          if (threads.size === 0) {
            hook.detach();
            if (aliveTimeout !== null) {
              clearTimeout(aliveTimeout);
            }
            _notifyEvents(completedThreads, resolve);
          }
        }
      }
    });

    tickAlive();

    let aliveTimeout = null;
    function tickAlive () {
      if (config.timeout === 0) {
        return;
      }
      if (aliveTimeout !== null) {
        clearTimeout(aliveTimeout);
      }
      const milliseconds = (config.timeout >> 0) * 1000;
      aliveTimeout = setTimeout(selfDestruct, milliseconds);
    }

    function selfDestruct () {<commit_msg>Fix uninitialized Timeout issue in the stalker<commit_after>/* eslint-disable comma-dangle */
'use strict';

const eventsByThread = {};
const inModules = [];

module.exports = {
  stalkFunction: stalkFunction,
  stalkEverything: stalkEverything,
};

function stalkFunction (config, address) {
  return new Promise((resolve, reject) => {
    const recursiveCountByThread = {};
    const threads = new Set();
    const completedThreads = new Set();
    let aliveTimeout = null;

    _clearEvents();
    _initModules(config);

    const hook = Interceptor.attach(address, {
      onEnter () {
        tickAlive();

        this.myThreadId = Process.getCurrentThreadId();
        let recursiveCount = recursiveCountByThread[this.myThreadId] || 0;
        recursiveCount++;
        recursiveCountByThread[this.myThreadId] = recursiveCount;

        if (recursiveCount === 1) {
          threads.add(this.myThreadId);
          _followHere(config);
        }
      },

      onLeave () {
        tickAlive();

        let recursiveCount = recursiveCountByThread[this.myThreadId];
        recursiveCount--;
        recursiveCountByThread[this.myThreadId] = recursiveCount;

        if (recursiveCount === 0) {
          threads.delete(this.myThreadId);
          completedThreads.add(this.myThreadId);
          _unfollowHere();
          if (threads.size === 0) {
            hook.detach();
            if (aliveTimeout !== null) {
              clearTimeout(aliveTimeout);
              aliveTimeout = null;
            }
            _notifyEvents(completedThreads, resolve);
          }
        }
      }
    });

    tickAlive();

    function tickAlive () {
      if (config.timeout === 0) {
        return;
      }
      if (aliveTimeout !== null) {
        clearTimeout(aliveTimeout);
      }
      const milliseconds = (config.timeout >> 0) * 1000;
      aliveTimeout = setTimeout(selfDestruct, milliseconds);
    }

    function selfDestruct () {
{'fraction_non_alphanumeric': 0.1154649947753396, 'fraction_numerical': 0.00522466039707419, 'mean_word_length': 2.3411867364746946, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3584350', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1048, 'n_words': 210}