hyperjumptech / monika

Monika is a command line application to monitor every part of your web app using a simple YAML configuration file. Get alert not only when your site is down but also when it's slow.
https://monika.hyperjump.tech
MIT License
605 stars 67 forks source link

feat(native fetch): Handle Node.js fetch errors #1252

Closed syamsudotdev closed 8 months ago

syamsudotdev commented 8 months ago

Monika Pull Request (PR)

This PR resolves #1246

What feature/issue does this PR add

  1. Handle Node.js fetch errors based on Node.js Undici errors

How did you implement / how did you fix it

  1. Expand low-level HTTP status code outside Axios' code range when handling Node.js fetch errors
  2. Add documentation for new low-level HTTP status codes
  3. Split HTTP request between using Axios and Node.js fetch
  4. Split exception handling between Axios and Node.js fetch error

How to test

  1. Given monika.yml configuration
    probes:
    - id: '2'
    name: HTML form submission
    description: simulate html form submission
    interval: 1
    requests:
      - url: https://httpbin.org/post
        timeout: 100
        method: POST
        headers:
          Accept: application/json
        body:
          username: someusername
          password: somepassword
  2. Run npm run start -- --native-fetch --verbose -r 1
  3. Observe log for Node.js fetch use and timeout error image
codecov[bot] commented 8 months ago

Codecov Report

Attention: Patch coverage is 27.86885% with 44 lines in your changes are missing coverage. Please review.

Project coverage is 62.72%. Comparing base (11a8d6a) to head (672d8b8).

Files Patch % Lines
src/components/probe/prober/http/request.ts 27.86% 43 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1252 +/- ## ========================================== - Coverage 63.25% 62.72% -0.54% ========================================== Files 111 111 Lines 3326 3364 +38 Branches 574 590 +16 ========================================== + Hits 2104 2110 +6 - Misses 1032 1064 +32 Partials 190 190 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

ilmiawan commented 8 months ago

Please sync with the main branch first.