I have a Next.js 13.4.13 site fetching data from Sanity.io with next-sanity
. However, whenever I boot up two things are happening:
我有一个Next.js 13.4.13站点使用Next-Sanity从Sanity.io获取数据。然而,每当我启动时,都会发生两件事:
- new updated data from Sanity is not being fetched
- I'm getting a huge stream of undici AbortError responses in the Console as per:
DOMException [AbortError]: This operation was aborted
at Object.fetch (node:internal/deps/undici/undici:11457:11)
DOMException [AbortError]: This operation was aborted
at Object.fetch (node:internal/deps/undici/undici:11457:11)
DOMException [AbortError]: This operation was aborted
at Object.fetch (node:internal/deps/undici/undici:11457:11)
DOMException [AbortError]: This operation was aborted
at Object.fetch (node:internal/deps/undici/undici:11457:11)
DOMException [AbortError]: This operation was aborted
at Object.fetch (node:internal/deps/undici/undici:11457:11)
DOMException [AbortError]: This operation was aborted
at Object.fetch (node:internal/deps/undici/undici:11457:11)
DOMException [AbortError]: This operation was aborted
at Object.fetch (node:internal/deps/undici/undici:11457:11)
DOMException [AbortError]: This operation was aborted
at Object.fetch (node:internal/deps/undici/undici:11457:11)
DOMException [AbortError]: This operation was aborted
at Object.fetch (node:internal/deps/undici/undici:11457:11)
DOMException [AbortError]: This operation was aborted
at Object.fetch (node:internal/deps/undici/undici:11457:11)
DOMException [AbortError]: This operation was aborted
at Object.fetch (node:internal/deps/undici/undici:11457:11)
DOMException [AbortError]: This operation was aborted
at Object.fetch (node:internal/deps/undici/undici:11457:11)
DOMException [AbortError]: This operation was aborted
at Object.fetch (node:internal/deps/undici/undici:11457:11)
DOMException [AbortError]: This operation was aborted
at Object.fetch (node:internal/deps/undici/undici:11457:11)
These errors give no advice on where/what is causing this error so I'm struggling to identify why it's happening. does anyone have any guidance on what Undici is and what could be triggering this?
这些错误没有给出任何关于导致此错误的位置/原因的建议,所以我很难找出为什么会发生这种错误。有没有人知道Undici是什么,什么可能会引发这一事件?
更多回答
优秀答案推荐
EDIT: I removed my previous answer as it wasn't the resolution. For me it seems to have something to do with Next.js cache.
编辑:我删除了之前的答案,因为它不是解决方案。对我来说,这似乎与Next.js缓存有关。
I have 2 server-side fetch functions and both are calling the same method which is querying a Pocketbase database.
我有两个服务器端FETCH函数,它们都调用相同的方法,即查询Pocketbase数据库。
// fetch the CII ratio averages per vessel group
const ciiGroupData = await fetch(`${process.env.APP_URL}/api/cii/group`, { next: { revalidate: 1 }, headers: { Cookie: `next_secret=${process.env.AUTH_SECRET!}` } });
const globalGroupCii = await ciiGroupData.json();
// fetch the CII ratio averages per vessel
const ciiRatioAvgData = await fetch(`${process.env.APP_URL}/api/cii/ratio-avg`, { next: { revalidate: 1 }, headers: { Cookie: `next_secret=${process.env.AUTH_SECRET!}` } });
const globalCIIRatioAvg = await ciiRatioAvgData.json();
Both are calling the getCIIforShip
method. Adding cache: "no-store"
to this Pocketbase method seems to have solved the problem. This method uses the native fetch
underneath and they just added support to other native fetch
options.
两者都在调用getCIIforShip方法。在这个Pocketbase方法中添加缓存:“no-store”似乎已经解决了这个问题。该方法使用下面的本机FETCH,它们只是添加了对其他本机FETCH选项的支持。
export async function getCIIforShip(shipId: string) {
const cii = await pb.collection("cii_reports").getList(1, 500, {
filter: `ship = "${shipId}"`,
sort: "data_until_date",
cache: "no-store",
});
return cii;
}
I've also had issues with authentication in Pocketbase because of Next.js cache, but again, cache: "no-store"
did the trick.
由于Next.js缓存的原因,我在Pocketbase中的身份验证方面也遇到了问题,但同样,缓存:“no-store”成功了。
更多回答
我是一名优秀的程序员,十分优秀!