-
Notifications
You must be signed in to change notification settings - Fork 35
Sync token #239
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
Sync token #239
Conversation
Staging -->. master
abhishek305
left a comment
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.
- I would suggest just revisit the sync retry logic instead of refactoring the existing flow
| exports.setGlobalConfig = (config) => { | ||
| globalConfig = { ...config }; // Creates a new copy to avoid unintended mutations | ||
| }; |
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.
what is globalConfig ?
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.
globalConfig is just a way to store the config safely so we don’t accidentally modify the original object. It helps keep things consistent across different functions that need the same config values (like httpRetries for retries).
To prevent accidental overwrites, we use setGlobalConfig() to update it safely.
It was added to make sure we always use the correct config throughout the module.
Let me know if you think it could cause any issues.. @abhishek305
src/fetch.js
Outdated
| activity.end(); | ||
|
|
||
| return { contentstackData }; | ||
| return { contentstackData: syncData.data } |
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.
would this create an issue when accessing syncData as previously it was contentstackData.syncData ? now its changed?
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.
Great Catch, let me remove that possibility by restoring the data structure..
| const normalizeLimit = (limit) => { | ||
| if (limit > 100) { | ||
| console.error('Limit cannot exceed 100. Setting limit to 50.'); | ||
| return 50; | ||
| } | ||
| return limit; | ||
| }; |
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.
what is this limit ? and do we actually need to refactor that?
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.
That is a limitation that limit value cannot be set more than 100, incase user does that, we should by default send 50 to the api.
Hence normalizing the logic, incase we make any changes to this limitation, it will be easy to find and make any changes needed
|
@Contentstack-AnkitaD lets close this PR and refactor the retry approach for synctoken |
Refactor the fetch.js file inorder to make debugging the sync token error more better and easy to understand.