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

MaxListenersExceededWarning when running fetch tests #32951

Closed
mxschmitt opened this issue Oct 4, 2024 · 1 comment · Fixed by #32956
Closed

MaxListenersExceededWarning when running fetch tests #32951

mxschmitt opened this issue Oct 4, 2024 · 1 comment · Fixed by #32956
Assignees
Labels

Comments

@mxschmitt
Copy link
Member

mxschmitt commented Oct 4, 2024

tests/async/test_fetch_global.py::test_should_json_stringify_body_when_content_type_is_application_json[chromium-serialization2] (node:21485) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 lookup listeners added to [Socket]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit
    at genericNodeError (node:internal/errors:984:15)
    at wrappedFn (node:internal/errors:538:14)
    at _addListener (node:events:593:17)
    at Socket.addListener (node:events:611:10)
    at Readable.on (node:internal/streams/readable:1126:35)
    at ClientRequest.<anonymous> (/Users/maxschmitt/Developer/playwright-python/playwright/driver/package/lib/server/fetch.js:396:16)
    at ClientRequest.emit (node:events:531:35)
    at tickOnSocket (node:_http_client:850:7)
    at onSocketNT (node:_http_client:913:5)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
(node:21485) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 secureConnect listeners added to [Socket]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit
    at genericNodeError (node:internal/errors:984:15)
    at wrappedFn (node:internal/errors:538:14)
    at _addListener (node:events:593:17)
    at Socket.addListener (node:events:611:10)
    at Readable.on (node:internal/streams/readable:1126:35)
    at ClientRequest.<anonymous> (/Users/maxschmitt/Developer/playwright-python/playwright/driver/package/lib/server/fetch.js:402:16)
    at ClientRequest.emit (node:events:531:35)
    at tickOnSocket (node:_http_client:850:7)
    at onSocketNT (node:_http_client:913:5)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)

When running the Python fetch tests: pytest --browser chromium tests/async/test_fetch_browser_context.py tests/async/test_fetch_global.py

Leaks here:

        socket.on('lookup', () => {
          dnsLookupAt = (0, _utils.monotonicTime)();
        });
@mxschmitt mxschmitt added the v1.48 label Oct 4, 2024
Skn0tt added a commit that referenced this issue Oct 7, 2024
Closes #32951

`node:http` reuses TCP Sockets under the hood. We weren't cleaning up
our listeners, leading to the `MaxListenersExceededWarning`.

This PR adds cleanup logic. It also raises the warning threshhold, so
that it doesn't trigger until there's 100 concurrent requests over the
same socket.
Skn0tt added a commit that referenced this issue Oct 8, 2024
Closes #32951

`node:http` reuses TCP Sockets under the hood. We weren't cleaning up
our listeners, leading to the `MaxListenersExceededWarning`.

This PR adds cleanup logic. It also raises the warning threshhold, so
that it doesn't trigger until there's 100 concurrent requests over the
same socket.
@Skn0tt
Copy link
Member

Skn0tt commented Oct 14, 2024

I've used microsoft/playwright-python#2584 to test 1.49.0-alpha-2024-10-07 vs 1.49.0-alpha-2024-10-08, which contains #32956. The test confirmed that it fixes the MaxListenersExceededWarning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants