Comments (5)
Can you run node
with the --trace-warnings
to get a stack trace?
from got.
Node is already running with trace-warnings flag. That's all stack trace we've got 😮💨
from got.
Without catching anything I get
Uncaught exception: RequestError: socket hang up
at ClientRequest.<anonymous> (file:///XXXXXXXXX/node_modules/got/dist/source/core/index.js:792:107)
at Object.onceWrapper (node:events:628:26)
at ClientRequest.emit (node:events:525:35)
at Socket.socketCloseListener (node:_http_client:469:11)
at Socket.emit (node:events:525:35)
at connResetException (node:internal/errors:718:14)
at Socket.socketCloseListener (node:_http_client:469:25)
at Socket.emit (node:events:525:35)
at TCP.<anonymous> (node:net:320:12)
from got.
This is happening to me as well when mocking an API with msw
and returning a network error @sindresorhus :
import { graphql, HttpResponse, http } from 'msw';
import { setupServer } from 'msw/node';
import { got } from 'got';
let networkErrorCounter = 0;
const handlers = [
http.get('https://unstable.com/v1/network-error', () => {
if (networkErrorCounter === 0) {
networkErrorCounter += 1;
return HttpResponse.error();
}
return new HttpResponse(null, {
status: 200,
});
}),
];
const server = setupServer(...handlers);
describe('got tests', () => {
beforeAll(() => server.listen());
afterEach(() => server.resetHandlers());
afterAll(() => server.close());
it('should retry requests on network error', async () => {
const result = await got.get('https://unstable.com/v1/network-error');
expect(result.statusCode).toBe(200);
expect.assertions(1);
});
});
Fails when running npx vitest
with:
Error: socket hang up
❯ connResetException node:internal/errors:717:14
❯ _destroy node:_http_client:880:15
❯ TLSSocket.<anonymous> node:_http_client:897:11
❯ TLSSocket.<anonymous> node:internal/util:464:12
❯ onclose node:internal/streams/end-of-stream:148:25
❯ processTicksAndRejections node:internal/process/task_queues:77:11
from got.
I am happy to provide a fully working reproducible example if needed but the above code snippet should work
from got.
Related Issues (20)
- Jest has detected open handle JSSTREAM http2-wrapper HOT 1
- Stack trace back to client code
- beforeError hook not called on ERR_UNSUPPORTED_PROTOCOL
- Add options parameter to beforeRetry hook HOT 1
- Request Timeouts increase eventloop lag
- Bun throws error 'A retry listener has been attached already' HOT 6
- Request fails with NGHTTP2_INTERNAL_ERROR for http2 requests HOT 3
- Request fails with NGHTTP2_PROTOCOL_ERROR for http2 requests HOT 2
- Too Many Requests Error HOT 5
- Socket hang up error when using the delete method with stream API HOT 4
- Allow dynamically set followRedirect HOT 1
- Got does not recover from a TCP socket timeout when using HTTP2 HOT 1
- Make library name more precise for search HOT 1
- Allow typing the body of a `RequestError` response
- `Response<string>` returned rather than a json response HOT 2
- Is v13 still maintained/supported? HOT 1
- Hangs on revalidated response from cache
- Infinite redirection with special characters in the redirected URL HOT 1
- Support `servername` https option
- How to get traffic usage per request? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from got.