Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/site/next-data/generators/majorNodeReleases.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import nodevu from '@nodevu/core';

import { fetchWithRetry } from '#site/util/fetch';
import { fetchWithRetry } from '#site/next.fetch.mjs';

/**
* Filters Node.js release data to return only major releases with documented support.
Expand Down
2 changes: 1 addition & 1 deletion apps/site/next-data/generators/supportersData.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OPENCOLLECTIVE_MEMBERS_URL } from '#site/next.constants.mjs';
import { fetchWithRetry } from '#site/util/fetch';
import { fetchWithRetry } from '#site/next.fetch.mjs';

/**
* Fetches supporters data from Open Collective API, filters active backers,
Expand Down
2 changes: 1 addition & 1 deletion apps/site/next-data/generators/vulnerabilities.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { VULNERABILITIES_URL } from '#site/next.constants.mjs';
import { fetchWithRetry } from '#site/util/fetch';
import { fetchWithRetry } from '#site/next.fetch.mjs';

const RANGE_REGEX = /([<>]=?)\s*(\d+)(?:\.(\d+))?/;
const V0_REGEX = /^0\.\d+(\.x)?$/;
Expand Down
2 changes: 1 addition & 1 deletion apps/site/next.calendar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
BASE_CALENDAR_URL,
SHARED_CALENDAR_KEY,
} from './next.calendar.constants.mjs';
import { fetchWithRetry } from './util/fetch';
import { fetchWithRetry } from './next.fetch.mjs';

/**
*
Expand Down
38 changes: 38 additions & 0 deletions apps/site/next.fetch.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* @typedef { RequestInit & { maxRetry?: number; delay?: number; }} RetryOptions
*/

const isTimeoutError = e =>
e instanceof Error &&
typeof e.cause === 'object' &&
e.cause !== null &&
'code' in e.cause &&
e.cause.code === 'ETIMEDOUT';

const sleep = ms => new Promise(r => setTimeout(r, ms));

/**
* Does a fetch with retry logic for network errors and timeouts.
*
* @param {string} url
* @param {RetryOptions} [options]
* @returns {Promise<Response>}
*/
export const fetchWithRetry = async (
url,
{ maxRetry = 3, delay = 100, ...options } = {}
) => {
const retries = Math.max(1, Number(maxRetry) || 1);
const backoff = Math.max(0, Number(delay) || 0);

const attemptFetch = attempt =>
fetch(url, options).catch(e => {
if (attempt === retries || !isTimeoutError(e)) {
throw e;
}

return sleep(backoff * attempt).then(() => attemptFetch(attempt + 1));
});

return attemptFetch(1);
};
30 changes: 15 additions & 15 deletions apps/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
"@node-core/ui-components": "workspace:*",
"@node-core/website-i18n": "workspace:*",
"@nodevu/core": "0.3.0",
"@opentelemetry/api-logs": "~0.206.0",
"@opentelemetry/instrumentation": "~0.206.0",
"@opentelemetry/api-logs": "~0.211.0",
"@opentelemetry/instrumentation": "~0.211.0",
"@opentelemetry/resources": "~1.30.1",
"@opentelemetry/sdk-logs": "~0.206.0",
"@opentelemetry/sdk-logs": "~0.211.0",
"@orama/core": "^1.2.16",
"@orama/ui": "^1.5.4",
"@radix-ui/react-tabs": "^1.1.13",
Expand All @@ -50,17 +50,17 @@
"@types/node": "catalog:",
"@types/react": "catalog:",
"@vcarl/remark-headings": "~0.1.0",
"@vercel/analytics": "~1.5.0",
"@vercel/analytics": "~1.6.1",
"@vercel/otel": "~2.1.0",
"@vercel/speed-insights": "~1.2.0",
"@vercel/speed-insights": "~1.3.1",
"classnames": "catalog:",
"cross-env": "catalog:",
"feed": "~5.1.0",
"github-slugger": "~2.0.0",
"gray-matter": "~4.0.3",
"mdast-util-to-string": "^4.0.0",
"next": "16.0.10",
"next-intl": "~4.5.3",
"next": "16.1.6",
"next-intl": "~4.8.2",
"next-themes": "~0.4.6",
"postcss-calc": "~10.1.1",
"react": "catalog:",
Expand All @@ -80,17 +80,17 @@
},
"devDependencies": {
"@flarelabs-net/wrangler-build-time-fs-assets-polyfilling": "^0.0.1",
"@next/eslint-plugin-next": "16.0.7",
"@next/eslint-plugin-next": "16.1.6",
"@node-core/remark-lint": "workspace:*",
"@opennextjs/cloudflare": "^1.14.7",
"@playwright/test": "^1.57.0",
"@opennextjs/cloudflare": "^1.16.3",
"@playwright/test": "^1.58.1",
"@testing-library/user-event": "~14.6.1",
"@types/mdast": "^4.0.4",
"@types/mdx": "^2.0.13",
"@types/semver": "~7.7.1",
"babel-plugin-react-compiler": "^1.0.0",
"dedent": "^1.7.1",
"eslint-config-next": "16.1.1",
"eslint-config-next": "16.1.6",
"eslint-plugin-mdx": "~3.6.2",
"eslint-plugin-react": "~7.37.5",
"eslint-plugin-react-hooks": "^7.0.1",
Expand All @@ -100,15 +100,15 @@
"mdast-util-from-markdown": "^2.0.2",
"nock": "^14.0.10",
"remark-frontmatter": "^5.0.0",
"stylelint": "16.26.1",
"stylelint-config-standard": "39.0.1",
"stylelint": "17.1.1",
"stylelint-config-standard": "40.0.0",
"stylelint-order": "7.0.1",
"stylelint-selector-bem-pattern": "4.0.1",
"tsx": "^4.21.0",
"typescript": "catalog:",
"typescript-eslint": "~8.50.1",
"typescript-eslint": "~8.54.0",
"user-agent-data-types": "0.4.2",
"wrangler": "^4.59.1"
"wrangler": "^4.63.0"
},
"imports": {
"#site/*": [
Expand Down
Loading
Loading