-
-
Notifications
You must be signed in to change notification settings - Fork 935
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
The onCancel
handler was attached after the promise settled
#1187
Comments
The same error. |
Simplest repro: const http = require('http');
const got = require('.').extend({
timeout: 20,
retry: {
limit: 1
}
});
const server = http.createServer((_request, response) => {
response.write('ok');
});
server.listen(45678, 'localhost', async () => {
try {
const {body} = await got('http://localhost:45678/');
console.log(body);
} catch (error) {
console.log('promise rejected', error);
}
}); |
Wow, in fact there are 3 unhandled errors when running inside tests. |
Still getting this error on 11.3.0 |
@cjroebuck Can you post reproducible code please? |
Hmm. It's happening about once per 12-24 hours, in production, Sorry I'm not sure how to repro. These are the options I'm using though: const gotOpts = {
form: query,
timeout: 10000,
throwHttpErrors: false,
retry: {
limit: 2,
calculateDelay: ({ attemptCount, retryOptions, error, computedValue }) => {
if (computedValue) {
// let retryIn = 1000 * Math.pow(2, attemptCount) + Math.random() * 100;
logger.warn("Got an error from engine, retry in", computedValue, longRequestId, { attemptCount, error: error.message });
return computedValue;
}
logger.info("Do not retry", error.message, longRequestId)
return 0;
},
methods: ['POST'] as Method[]
}
};
let response = await got.post(someUrl, gotOpts); stack trace:
|
@cjroebuck Thanks. What Node.js version are you using? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
When there's a timeout. I think I know how to reproduce this. Thanks for the info. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@cjroebuck Is the error an unhandled promise or you caught it in the |
Unhandled rejection. |
The query variable is a query string object, next time it happens I'll try and grab the contents. I have updated to node 14 in prod though based on what myfreer said initially. |
@cjroebuck Can you replace let response = await got.post(someUrl, gotOpts); with let response = await got.post(someUrl, gotOpts).on('request', request => {
const timestamp = Date.now();
request.once('error', error => {
console.log(`${timestamp} Received error:`, error);
});
request.once('response', response => {
console.log(`${timestamp} Got response`);
response.on('readable', () => {
console.log(`${timestamp} Response is readable`, response.complete);
});
response.once('end', () => {
console.log(`${timestamp} Response ended`);
});
});
}); If you could send me the logs, it would be great. |
@cjroebuck Does setting |
@cjroebuck What's the status of the |
You can also make |
Related: #1308 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This should be fixed in |
i meet the issue on version:
|
That's probably #1489 |
Describe the bug
Using
Promise API
with socket timeout and retry, this does not reproduce on Node.js 14.0.0.Actual behavior
Promise rejected before retry, and stderr printed message like below:
Edited: some logs showing the timestamp.
Expected behavior
Retryed.
Code to reproduce
Checklist
The text was updated successfully, but these errors were encountered: