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

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

Merged
merged 3 commits into from
Mar 15, 2024

Conversation

syamsudotdev
Copy link
Contributor

@syamsudotdev syamsudotdev commented Mar 13, 2024

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
  1. Run npm run start -- --native-fetch --verbose -r 1
  2. Observe log for Node.js fetch use and timeout error
    image

@syamsudotdev syamsudotdev self-assigned this Mar 13, 2024
Copy link

codecov bot commented Mar 13, 2024

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 ⚠️
Additional details and impacted files
@@            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              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ilmiawan
Copy link
Contributor

Please sync with the main branch first.

Copy link
Contributor

@dennypradipta dennypradipta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done.

@dennypradipta dennypradipta merged commit ab0f741 into hyperjumptech:main Mar 15, 2024
7 checks passed
@syamsudotdev syamsudotdev deleted the handle-fetch-errors branch March 15, 2024 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle error with Node.js fetch
3 participants