whoiser
whoiser copied to clipboard
WHOISER does not respect the timeout supplied and takes forever when an invalid TLD is supplied
Version(s) affected: "^1.17.3",
Description
I'm querying domain data using Whoiser but when given a timeout of 5000 it does not respect that and it ends up quering for over 30s
Also if given an invalid URL e.g "hereandthere" it takes forever to return a response for invalid TLD. This is after supplying a 5s timeout
How to reproduce
` interface DomainData { status: "success" | "error"; data: WhoisSearchResult | null; message: string; }
export async function getDomainData(domain: string): Promise<DomainData> { try { const domainData = await whoiser(domain, { timeout: 5000, });
if (!domainData) {
throw new Error("Domain details not found");
}
console.log("searched domain details:");
return {
status: "success",
message: "Domain details fetched successfully",
data: domainData,
};
} catch (error: any) { console.log("there is an error", error.message); return { status: "error", data: null, message: error.message || "An error occured while fetching domain details", }; } }
`
And here is the client
` const [data, setData] = useState<WhoisSearchResult | null>(null); const [isLoading, setIsLoading] = useState(false); const toast = useToast();
async function fetchData() { setIsLoading(true); const res = await getDomainData("hereandthere"); setIsLoading(false); if (res.data && res.status === "success") { setData(res.data); } toast({ title: "Error", description: res.message, status: res.status, duration: 9000, isClosable: true, }); }
`
loading is indefinate when invalid tlds are supplied for over 30seconds
Possible Solution
maybe fix the timeout to be respected if the request goes over 5 seconds then timeout should work
Additional context