Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error (0, assert_1.default)(s.listenerCount('data') > 0) #366

Open
younes-zeboudj opened this issue Feb 21, 2025 · 0 comments
Open

Error (0, assert_1.default)(s.listenerCount('data') > 0) #366

younes-zeboudj opened this issue Feb 21, 2025 · 0 comments

Comments

@younes-zeboudj
Copy link

younes-zeboudj commented Feb 21, 2025

I am getting this error quite frequently:


  (0, assert_1.default)(s.listenerCount('data') > 0)

    at ClientRequest.<anonymous> (C:\Users\DELL\Desktop\project\node_modules\https-proxy-agent\dist\index.js:150:34)
    at Object.onceWrapper (node:events:632:26)
    at ClientRequest.emit (node:events:529:35)
    at tickOnSocket (node:_http_client:841:7)
    at onSocketNT (node:_http_client:904:5)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21) {
  generatedMessage: true,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '=='
}

I don't know what could be the reason. The exception is thrown here:

// Some other status code that's not 200... need to re-play the HTTP
        // header "data" events onto the socket once the HTTP machinery is
        // attached so that the node core `http` can parse and handle the
        // error status code.
        // Close the original socket, and a new "fake" socket is returned
        // instead, so that the proxy doesn't get the HTTP request
        // written to it (which may contain `Authorization` headers or other
        // sensitive data).
        //
        // See: https://hackerone.com/reports/541502
        socket.destroy();
        const fakeSocket = new net.Socket({ writable: false });
        fakeSocket.readable = true;
        // Need to wait for the "socket" event to re-play the "data" events.
        req.once('socket', (s) => {
            debug('Replaying proxy buffer for failed request');
            (0, assert_1.default)(s.listenerCount('data') > 0);
            // Replay the "buffered" Buffer onto the fake `socket`, since at
            // this point the HTTP module machinery has been hooked up for
            // the user.
            s.push(buffered);
            s.push(null);
        });
        return fakeSocket;

File : \node_modules\https-proxy-agent\dist\index.js

NOTE:
Earlier than this I got a nodejs warning pointint to the same place:

(node:23488) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 socket listeners added to [ClientRequest]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:591:17)
    at ClientRequest.addListener (node:events:609:10)
    at ClientRequest.once (node:events:653:8)
    at HttpsProxyAgent.connect (C:\Users\DELL\Desktop\project\node_modules\https-proxy-agent\dist\index.js:148:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant