Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WHOISER does not respect the timeout supplied and takes forever when an invalid TLD is supplied #113

Open
bonface221 opened this issue Jul 31, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@bonface221
Copy link

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 {
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
image
image

@bonface221 bonface221 added the bug Something isn't working label Jul 31, 2024
@bonface221
Copy link
Author

This is next js and nextjs server actions (NEXTJS v14)

@bonface221
Copy link
Author

Possible resolves

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants