TypeError: Cannot read properties of undefined (reading 'error')
Hi im using react-tweet with next js 14, app router. This is my code for component:
import { Suspense } from "react"
import { TweetSkeleton, Tweet } from "react-tweet"
import { getTweet as _getTweet } from "react-tweet/api"
import type { TwitterEmbedProps } from "@/types"
export const TwitterEmbed = ({ twitterAttrs }: TwitterEmbedProps) => {
const { url } = twitterAttrs
const id = url.split("/").pop() // Extract the post ID from the URL
if (!id) {
return <div>Invalid Tweet URL</div>
}
console.log(id)
return (
<Suspense fallback={<TweetSkeleton />}>
<Tweet id={id} />
</Suspense>
)
}
It was working fine for while, now it stoped. I didnt do any changes that should broke it.
TypeError: Cannot read properties of undefined (reading 'error')
at fetchTweet (webpack-internal:///(rsc)/./node_modules/react-tweet/dist/api/fetch-tweet.js:65:30)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async getTweet (webpack-internal:///(rsc)/./node_modules/react-tweet/dist/api/get-tweet.js:10:43)
at async TweetContent (webpack-internal:///(rsc)/./node_modules/react-tweet/dist/tweet.js:17:24)
Changing id to static one, just to see if is something wrong with id variable still resultate with this error as above.
Same issue here! This error started showing very recently, and seems to be happening only locally.
yeah i can confirm that is only localy :) strange thing since it shouldnt block ip request locally. Is there solution for it? @FilipPano are you on static IP?
yeah i can confirm that is only localy :) strange thing since it shouldnt block ip request locally. Is there solution for it? @FilipPano are you on static IP?
I am using a dynamic IP.
issue fixed by self. still don't know what was cause.
I started seeing this error recently from:
- Next.js app API endpoint running locally: 200
- Next.js app API endpoint running at (Netlify): 200
- Next.js app API endpoint running at (Vercel): 404
- Cloudflare Worker (deployed & local): 500
this was also breaking for me in an OpenNext app on Cloudflare, did a little tinkering and I think it's because Node normally sends a default user-agent (appears to be node now, previously undici https://github.com/nodejs/undici/issues/2306) and Cloudflare's fetch doesn't. my workaround was just adding a user-agent in fetch options, e.g.
<Tweet
id="<some-tweet-id>"
fetchOptions={{
headers: {
"User-Agent": "node",
},
}}
/>