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

False-negative for paths that do not exist (404 error) #39

Open
jessevdp opened this issue Nov 20, 2019 · 0 comments
Open

False-negative for paths that do not exist (404 error) #39

jessevdp opened this issue Nov 20, 2019 · 0 comments

Comments

@jessevdp
Copy link

The package falsely (?) indicates that a server is not reachable if a page returns some HTTP error. I think this might be false-negative for HTTP errors like 404, in this case, the server is reachable, the client just tried to access some resource that doesn't exist, the server then decides to respond with a certain page.

I haven't tried any others, but I suspect this might be an issue with other 4xx errors too. Is a server reachable if the current request is not authenticated or unauthorized and therefore receives a 401 or 403?

👀 Example

I tried the following on Runkit, using version 4.0.0 of the package. To demonstrate that the server is indeed reachable I first tried requesting the base URL. To make sure this isn't simply a problem with requesting paths, I tried reaching a path I know exists. Lastly, I tried getting the status of a path I know doesn't exist.

var isReachable = require("is-reachable")

async function run() {
    const baseURL = await isReachable("https://sindresorhus.com/")
    const existingPath = await isReachable("https://sindresorhus.com/apps")
    const nonExistingPath = await isReachable("https://sindresorhus.com/foobar")
    console.log(`base URL reachable: ${baseURL}`)
    console.log(`existing path reachable: ${existingPath}`)
    console.log(`non-existing path reachable: ${nonExistingPath}`)
}

run()

Output:

"base URL reachable: true"
"existing path reachable: true"
"non-existing path reachable: false"

Visiting that non-existing path in the browser returns a 404 error—as expected.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants