Welcome to the Linux Foundation Forum!

Labs (ch-7 / labs-1) serverError validate

Options
maximilianofurtado
edited December 2022 in LFW212 Class Forum

Server error validation when the branded service is inactive:
The req.setTimeout (1500) on line 27 (validate.js) delays a short time for the response with statusCode 500.
And validation fails because the server does not respond in time.

Tnx

Comments

  • aalthawr
    aalthawr Posts: 1
    edited May 2021
    Options

    You can do something like this

    SPOILERS! -> ``` const boat = await got(`${boatSrv}/${id}`, {timeout: 600, retry:0}).json() const brand = await got(`${brandSrv}/${boat.brand}`, {timeout: 600, retry:0}).json() ```
  • maximilianofurtado
    Options

    cool, great solution.
    thank you so much @aalthawr !!

  • davidmarkclements
    Options

    @aalthawr thanks for this! I've wrapped your comment in a

    <

    details> element to avoid spoilers

  • gregsheppard
    Options

    Perfect! I had been looking through the got docs and didn't see anything as simple as what you posted @aalthawr.

  • dominik.urban
    Options

    @gregsheppard said:
    Perfect! I had been looking through the got docs and didn't see anything as simple as what you posted @aalthawr.

    https://www.npmjs.com/package/got#timeout
    Timeout is an option in the api docs. Kind of hard to grasp this.

  • davidmarkclements
    Options

    hard but necessary

  • fhs
    fhs Posts: 3
    edited November 2022
    Options

    Hi @davidmarkclements, I'm a bit confused about this issue. Do you mean 'hard but necessary' because adding the timeout option is necessary as a workaround for validate.js to succeed? Or would it also be necessary in production/the exam?

    If it is necessary besides validating with the script: could you please explain why? Which timeouts are colliding and why etc?

  • fhs
    fhs Posts: 3
    Options

    @fhs said:
    Hi @davidmarkclements, I'm a bit confused about this issue. Do you mean 'hard but necessary' because adding the timeout option is necessary as a workaround for validate.js to succeed? Or would it also be necessary in production/the exam?

    If it is necessary besides validating with the script: could you please explain why? Which timeouts are colliding and why etc?

    Nevermind, found an excellent answer in the forum: https://forum.linuxfoundation.org/discussion/861101/things-about-ch7-lab1#latest

  • xdxmxc
    xdxmxc Posts: 139
    Options

    good place to close as duplicate

This discussion has been closed.

Categories

Upcoming Training