Getting test timed out on project test cases when it works fine for me

Tell us what’s happening:
In the URL shortener microservice project, I have used hash function from the crypto package for hashing. Everything works fine for me. But, when I submit the 3rd test gets timed out. Redirecting always correctly in my computer browser. Since the test is getting timed out, is it because of slow libraries, or slow network connection, or some mistake in my code? Please help me with this issue.
Thanks in advance :slight_smile:

Your project link(s)

solution: Glitch :・゚✧

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0

Challenge: URL Shortener Microservice

Link to the challenge:

When I try to run your site from your app, and I try to post:

Request URL:
Request Method: POST

with form data:


I get the response:

{"error":"Invalid URL"}

Sorry for the delay in reply. I have been working on this project since the last week. But there are no major break-throughs. I have made some observation on why the 3rd test was getting timed out. In the console logs, I found that the redirecting requests is all undefined during running the tests. Like <project-url>/api/shorturl/undefined is being asked during the tests, and the hash values are not being used. I thought it might be due to some spelling error in the json object that I am sending after the POST request, but I could not find any error. I use the same format of json object for returing errors, or short_urls as the link given in the challenge. I have manually tested the website but could find any bugs, which is causing undefined to be in place of short_url. I have also changed the hash from hex to numeric, to be sure if the parsing would not make it undefined. But there is no improvement. :sob:
However, I am not getting it as timed out anymore, it is showing as not passing. But from the console logs, it was clear that all the redirect requests were with the short_url value as undefined. This is where I feel, it is a silly error, but I am not able to find any mistakes in the code or during manual testing. :pensive:
Could you please find where am I going wrong?

When I run the test suite against your url:

I see this from the first test in the network tab:

  1. Request URL:
  2. Request Method: POST
  3. Status Code: 200



And this is the response:

{"error":"Invalid URL"}

I would figure out why that is happening.

I get the same response when I run that on your page.

When I try to generate the same bug, I find it to be working correctly. The POST request generates


I really do not know how it is not working from your side, or during testing… :face_with_monocle:

I finally found the mistake, and it was in URL validation. I had earlier used dns.lookup() to verify the URL to be valid. But to remove the protocol prefix like https://, I was using string.substring(string.indexOf('www')). But I found that the URLs which did not have www as a substring in them were not being handled correctly. I replaced dns.lookup with URL validation regex, and it passed. :partying_face:
Thank you for your help. :heart:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.