removed node-fetch workaround

Signed-off-by: Bond Yan <bondy@spotify.com>
This commit is contained in:
Bond Yan
2025-02-14 18:25:25 -05:00
parent 1922ed986f
commit 03d34525be
@@ -208,7 +208,7 @@ export class DefaultTechDocsCollatorFactory implements DocumentCollatorFactory {
targetPluginId: 'techdocs',
});
const searchIndexResponse = await fetch(
const searchIndex = await fetch(
DefaultTechDocsCollatorFactory.constructDocsIndexUrl(
techDocsBaseUrl,
entityInfo,
@@ -218,19 +218,7 @@ export class DefaultTechDocsCollatorFactory implements DocumentCollatorFactory {
Authorization: `Bearer ${techdocsToken}`,
},
},
);
// todo(@backstage/techdocs-core): remove Promise.race() when node-fetch is 3.x+
// workaround for fetch().json() hanging in node-fetch@2.x.x, fixed in 3.x.x
// https://github.com/node-fetch/node-fetch/issues/665
const searchIndex = await Promise.race([
searchIndexResponse.json(),
new Promise((_resolve, reject) => {
setTimeout(() => {
reject('Could not parse JSON in 5 seconds.');
}, 5000);
}),
]);
).then(res => res.json());
return searchIndex.docs.map((doc: MkSearchIndexDoc) => ({
...defaultTechDocsCollatorEntityTransformer(entity),