GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — interceptors: move throwOnError to interceptor by mertcanaltin · Pull Request #3331 · nodejs/undici

Conversation

@mertcanaltin

@mertcanaltin mertcanaltin commented Jun 16, 2024

Copy link
Copy Markdown
Member
  • Moved throwOnError handling to response-error interceptor.
  • Updated retry tests to handle 400 status code properly.

Test Issue:

  • Encountered 'BadRequestError' (status 400) in 'should not error if request is not meant to be retried' test.

Need assistance to resolve test failures.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Mert Can Altin
interceptors: move throwOnError to interceptor
4192b38
@mertcanaltin
mertcanaltin requested review from KhafraDev, metcoder95 and ronag June 16, 2024 18:22
KhafraDev
KhafraDev suggested changes Jun 16, 2024
View reviewed changes

@KhafraDev KhafraDev left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Please remove http-errors

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Uzlopak and mertcanaltin reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
Mert Can Altin
delete http-errors
e2321ec
mertcanaltin
mertcanaltin commented Jun 17, 2024
View reviewed changes
Comment thread lib/interceptor/response-error.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@mertcanaltin
mertcanaltin requested review from KhafraDev and Uzlopak June 17, 2024 05:27
ronag
ronag reviewed Jun 17, 2024
View reviewed changes
Comment thread lib/interceptor/response-error.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@mertcanaltin @ronag
Update response-error.js
7855225
Co-authored-by: Robert Nagy <[email protected]>
ronag
ronag reviewed Jun 17, 2024
View reviewed changes
Comment thread lib/interceptor/response-error.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

ronag
ronag reviewed Jun 17, 2024
View reviewed changes
Comment thread lib/interceptor/response-error.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@mertcanaltin @ronag
Update response-error.js
ea068eb
Co-authored-by: Robert Nagy <[email protected]>
ronag
ronag reviewed Jun 17, 2024
View reviewed changes
Comment thread lib/interceptor/retry.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@mertcanaltin @ronag
Update lib/interceptor/response-error.js
6782734
Co-authored-by: Robert Nagy <[email protected]>
@mertcanaltin
mertcanaltin requested a review from ronag June 17, 2024 12:00
metcoder95
metcoder95 reviewed Jun 18, 2024
View reviewed changes

@metcoder95 metcoder95 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Please do not forget to add docs and TS types 👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mertcanaltin reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread lib/interceptor/response-error.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/interceptor/response-error.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/interceptor/response-error.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/interceptor/response-error.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/interceptor/retry.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/interceptors/response-error.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Mert Can Altin added 5 commits June 19, 2024 12:21
Mert Can Altin
feat: added new undiciError
eb29a2a
Mert Can Altin
feat: enable interceptor by default
75fcf70
Mert Can Altin
feat: always throw error when interceptor is used
b2110d4
Mert Can Altin
feat: add option to throw error on specific status codes
e7512d3
Mert Can Altin
feat: export retry interceptor in index.js
2195af1
ronag
ronag reviewed Jun 20, 2024
View reviewed changes
Comment thread lib/interceptor/response-error.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

ronag
ronag reviewed Jun 20, 2024
View reviewed changes

@ronag ronag left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Could we also apply it to one of the API decoreators?

e.g.

diff --git a/lib/api/api-request.js b/lib/api/api-request.js
index ced5590d..f91b830a 100644
--- a/lib/api/api-request.js
+++ b/lib/api/api-request.js
@@ -13,7 +13,7 @@ class RequestHandler extends AsyncResource {
       throw new InvalidArgumentError('invalid opts')
     }
 
-    const { signal, method, opaque, body, onInfo, responseHeaders, throwOnError, highWaterMark } = opts
+    const { signal, method, opaque, body, onInfo, responseHeaders, highWaterMark } = opts
 
     try {
       if (typeof callback !== 'function') {
@@ -54,7 +54,6 @@ class RequestHandler extends AsyncResource {
     this.trailers = {}
     this.context = null
     this.onInfo = onInfo || null
-    this.throwOnError = throwOnError
     this.highWaterMark = highWaterMark
     this.signal = signal
     this.reason = null
@@ -132,20 +131,14 @@ class RequestHandler extends AsyncResource {
     this.callback = null
     this.res = res
     if (callback !== null) {
-      if (this.throwOnError && statusCode >= 400) {
-        this.runInAsyncScope(getResolveErrorBodyCallback, null,
-          { callback, body: res, contentType, statusCode, statusMessage, headers }
-        )
-      } else {
-        this.runInAsyncScope(callback, null, null, {
-          statusCode,
-          headers,
-          trailers: this.trailers,
-          opaque,
-          body: res,
-          context
-        })
-      }
+      this.runInAsyncScope(callback, null, null, {
+        statusCode,
+        headers,
+        trailers: this.trailers,
+        opaque,
+        body: res,
+        context
+      })
     }
   }
 
@@ -200,7 +193,7 @@ function request (opts, callback) {
   }
 
   try {
-    this.dispatch(opts, new RequestHandler(opts, callback))
+    this.compose(responseErrorInterceptor()).dispatch(opts, new RequestHandler(opts, callback))
   } catch (err) {
     if (typeof callback !== 'function') {
       throw err

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ronag
ronag reviewed Jun 20, 2024
View reviewed changes
Comment thread lib/interceptor/response-error.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@mertcanaltin @ronag
Update response-error.js
124e0db
Co-authored-by: Robert Nagy <[email protected]>
ronag
ronag reviewed Jun 20, 2024
View reviewed changes
Comment thread lib/api/index.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

ronag
ronag reviewed Jun 20, 2024
View reviewed changes
Comment thread lib/interceptor/response-error.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

ronag
ronag reviewed Jun 20, 2024
View reviewed changes
Comment thread lib/interceptor/response-error.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

metcoder95
metcoder95 reviewed Jul 5, 2024
View reviewed changes

@metcoder95 metcoder95 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Tests seems to be failing

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mertcanaltin reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread lib/api/index.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/interceptor/response-error.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/interceptor/response-error.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Mert Can Altin added 2 commits July 8, 2024 20:43
Mert Can Altin
Merge branch 'main' of https://github.com/mertcanaltin/undici into ad…
72cea91
…ded-response-error
Mert Can Altin
fix: test problem solved
ab619ec
@mertcanaltin

mertcanaltin commented Jul 8, 2024

Copy link
Copy Markdown
Member Author

Tests seems to be failing

Solved 🚀

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mertcanaltin
mertcanaltin requested a review from metcoder95 July 8, 2024 18:08
metcoder95
metcoder95 reviewed Jul 9, 2024
View reviewed changes

@metcoder95 metcoder95 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Let's add the respective TS types and docs 👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mertcanaltin reacted with thumbs up emoji mertcanaltin reacted with rocket emoji
All reactions
  • 👍 1 reaction
  • 🚀 1 reaction
@mertcanaltin

mertcanaltin commented Jul 9, 2024

Copy link
Copy Markdown
Member Author

Let's add the respective TS types and docs 👍

Which md file should I put the doc in, do you have any suggestions?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Mert Can Altin
added types
d5b2eb0
@metcoder95

metcoder95 commented Jul 10, 2024

Copy link
Copy Markdown
Member

Which md file should I put the doc in, do you have any suggestions?

Within Dispatcher.md, there's a section there for interceptors that outlines the built-in ones 👍

mertcanaltin reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Mert Can Altin
added Interceptor info in md
e0dd09d
@mertcanaltin
mertcanaltin requested review from mcollina and metcoder95 July 10, 2024 10:20
metcoder95
metcoder95 reviewed Jul 11, 2024
View reviewed changes

@metcoder95 metcoder95 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks! It LGTM, just smaller comments on the docs 👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mertcanaltin reacted with thumbs up emoji mertcanaltin reacted with rocket emoji
All reactions
  • 👍 1 reaction
  • 🚀 1 reaction
Comment thread docs/docs/api/Dispatcher.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread docs/docs/api/Dispatcher.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Mert Can Altin
repair doc
f10fc30
@mertcanaltin
mertcanaltin requested a review from metcoder95 July 11, 2024 08:03
ronag
ronag approved these changes Jul 11, 2024
View reviewed changes
KhafraDev
KhafraDev suggested changes Jul 11, 2024
View reviewed changes
Comment thread lib/interceptor/response-error.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@mertcanaltin @KhafraDev
Update lib/interceptor/response-error.js
ccd83e6
Co-authored-by: Khafra <[email protected]>
KhafraDev
KhafraDev approved these changes Jul 11, 2024
View reviewed changes
@mertcanaltin mertcanaltin added the interceptors Pull requests or issues related to Dispatcher Interceptors label Jul 11, 2024
@ronag
ronag merged commit 0ea1074 into nodejs:main Jul 11, 2024
@metcoder95 metcoder95 mentioned this pull request Jul 14, 2024
interceptors: move throwOnError to interceptor #3275
Closed
@metcoder95 metcoder95 added the backport v6.x label Sep 12, 2024
github-actions Bot pushed a commit that referenced this pull request Sep 12, 2024
@mertcanaltin @github-actions
interceptors: move throwOnError to interceptor (#3331)
301bb5b
(cherry picked from commit 0ea1074)
@github-actions github-actions Bot mentioned this pull request Sep 12, 2024
feat(Backport v6.x): move throwOnError to interceptor #3595
Merged
@github-actions github-actions Bot mentioned this pull request Dec 3, 2024
[Release] v7.1.0 #3922
Merged
This was referenced Dec 16, 2024
[Release] v7.1.1 #3952
Closed
[Release] v7.2.0 #3962
Merged
@github-actions github-actions Bot mentioned this pull request Mar 12, 2025
[Release] v6.21.2 #4092
Closed
@github-actions github-actions Bot mentioned this pull request May 12, 2025
[Release] v6.21.3 #4211
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ronag ronag ronag approved these changes
@Uzlopak Uzlopak Awaiting requested review from Uzlopak
@mcollina mcollina Awaiting requested review from mcollina
@metcoder95 metcoder95 Awaiting requested review from metcoder95
+1 more reviewer
@KhafraDev KhafraDev KhafraDev approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

backport v6.x interceptors Pull requests or issues related to Dispatcher Interceptors

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@mertcanaltin @ronag @metcoder95 @Uzlopak @KhafraDev
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.