-
Notifications
You must be signed in to change notification settings - Fork 74
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
fix: use @vercel/fetch to better guard against network glitches #216
Conversation
The disabled network test is not failing. A bit unsure on how to actually verify that the client still produces an error. (@vercel/fetch will do magic retries under the hood) |
At work we've set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running it locally with a lot of traffic I got this error:
TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received null
at validateString (internal/validators.js:120:11)
at Url.parse (url.js:159:3)
at urlParse (url.js:154:13)
at fetchCachedDns (/home/ivarconr/code/unleash-client-node/node_modules/@vercel/fetch-cached-dns/index.js:62:30)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async /home/ivarconr/code/unleash-client-node/node_modules/@vercel/fetch-retry/index.js:52:23
at async fetchRetry (/home/ivarconr/code/unleash-client-node/node_modules/@vercel/fetch-retry/index.js:48:14)
at async vercelFetch (/home/ivarconr/code/unleash-client-node/node_modules/@vercel/fetch/index.js:74:11) {
code: 'ERR_INVALID_ARG_TYPE',
url: 'https://unleash.herokuapp.com/api/client/features',
opts: {
method: 'GET',
timeout: 10000,
headers: Headers { [Symbol(map)]: [Object: null prototype] },
agent: HttpsAgent {
_events: [Object: null prototype],
_eventsCount: 4,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object],
requests: {},
sockets: {},
freeSockets: [Object],
keepAliveMsecs: 30000,
keepAlive: true,
maxSockets: Infinity,
maxFreeSockets: 256,
freeSocketKeepAliveTimeout: 15000,
timeout: 10000,
socketActiveTTL: null,
createSocketCount: 2,
createSocketCountLastCheck: 0,
createSocketErrorCount: 0,
createSocketErrorCountLastCheck: 0,
closeSocketCount: 0,
closeSocketCountLastCheck: 0,
errorSocketCount: 0,
errorSocketCountLastCheck: 0,
requestCount: 58,
requestCountLastCheck: 0,
timeoutSocketCount: 0,
timeoutSocketCountLastCheck: 0,
maxCachedSessions: 100,
_sessionCache: [Object],
[Symbol(kCapture)]: false
},
redirect: 'manual',
onRedirect: [Function]
}
const agent = getAgent(new URL('https://unleash.hosted.com')); | ||
t.true(agent instanceof https.Agent); | ||
}); | ||
import { buildHeaders } from '../lib/request'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit unsure on how to test that we get an agent with proper agent settings.
examples/simple_usage.js
Outdated
@@ -12,4 +14,4 @@ console.log('Fetching toggles from: http://unleash.herokuapp.com'); | |||
|
|||
setInterval(() => { | |||
console.log(`featureX enabled: ${isEnabled('featureX')}`); | |||
}, 1000); | |||
}, 100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bah, revert this, only me testing.
@@ -69,7 +65,6 @@ export const post = ({ url, appName, timeout, instanceId, headers, json }: PostR | |||
fetch(url, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably also configure our own retry
options.
It seems like I have opened an issue for this: |
I have been testing this module and found quite a few bugs.
Conclusion: We can not use this wrapper to guard against network errors, as it will introduce new once. Especially 1) is a problem for us. |
No description provided.