Skip to content

Commit

Permalink
docs(figma): add retry function after rate limit reached (#1477)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielleroux authored Sep 16, 2024
1 parent 084ab41 commit d17db32
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/documentation/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const config: Config = {
// Please change this to your repo.
editUrl:
'https://www.github.com/siemens/ix/edit/main/packages/documentation/',
remarkPlugins: useFastStart ? [] : [
remarkPlugins: [
figmaPlugin({
baseUrl: `${baseUrl}figma`,
figmaFolder: `${path.join(__dirname, 'static', 'figma')}`,
Expand Down
11 changes: 10 additions & 1 deletion packages/figma-plugin/src/figma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,15 @@ async function getImageResource(
'with node ids:',
ids
);
return null;

if (response.status === 429) {
console.log('🕰️ Retry after 60 seconds');
return new Promise((resolve) => {
setTimeout(() => {
resolve(getImageResource(fileName, nodeIds, figmaToken));
}, 60 * 1000);
});
}
}

const data = await response.json();
Expand Down Expand Up @@ -150,6 +158,7 @@ async function processImage(
}

export default (config: FigmaConfig) => {
console.log('Figma plugin running');
if (config.apiToken === undefined || config.apiToken === '') {
console.error('@siemens/figma-plugin no auth token provided');
return () => {};
Expand Down

0 comments on commit d17db32

Please sign in to comment.