Open wildcatco opened 1 year ago
Just wanted to follow up on this. I am rendering a large database and when deploying to Vercel it fails due to rate limiting.
Same issue on our end, really annoying we're not able to update our content with current limitation
Use redis to cache your data, then only use the redis data. Create a way to update the cache, or set a timer. This allows you to call your data as many times as needed.
Also, if you're calling data via Client, it will always try to make a request. If you're on development, it'll request twice per transaction.
I managed to get around this by modifying the package to add a delay and lower the concurrency.
// Add a new function at top level
function delay(duration) {
console.log("Delaying... 🕑", duration) // To make sure your module is read locally and not from npm. Comment it out later.
return new Promise(resolve => setTimeout(resolve, duration));
}
(...)
// Then call it from getPage var NotionCompatAPI = class { constructor(client) { this.client = client; } async getPage(rawPageId) { await delay(350);
const pageId = parsePageId(rawPageId);
(...)
2. Lower concurrency
async resolvePage(rootBlockId, { concurrency = 1 // Change this number from 4 to 1 } = {}) {
While you're in the file you can also disable this console log to make build output more readable:
// console.log("blocks.children.list", { blockId, cursor });
Most likely using both is an overkill, but I'm just doing it in a safe way at first.
It would make sense to add a PR to enable this optionally using a parameter in `getPage` call. I don't know if I will do it, but if I do I will link it here.
Description
I get 'too many requests' response when using getPage method. What is the rate limit of the reqeust?
Notion Test Page ID